瀏覽代碼

shower

master
Roderic Day 3 年之前
父節點
當前提交
006b70ddce
共有 1 個檔案被更改,包括 16 行新增0 行删除
  1. +16
    -0
      y2021/p13.py

+ 16
- 0
y2021/p13.py 查看文件

import toolkit


dots, instructions = text.split('\n\n')
dots = {eval(pair) for pair in dots.splitlines()}
ans1 = None
for line in instructions.splitlines():
axis, zz = line.split()[-1].split('=')
zz = int(zz)
if axis == 'x':
dots = {(x, y) if x < zz else (2 * zz - x, y) for x, y in dots}
elif axis == 'y':
dots = {(x, y) if y < zz else (x, 2 * zz - y) for x, y in dots}
if ans1 is None:
ans1 = len(dots)
ans2 = '\n' + toolkit.render({complex(*k): '#' for k in dots})

Loading…
取消
儲存