···11+import fileinput
22+from utils import print_grid, Point
33+44+55+DOTS = {}
66+FOLDS = []
77+88+99+# Read problem input
1010+data = ''.join([line for line in fileinput.input()])
1111+groups = [g.split('\n') for g in data.split('\n\n')]
1212+1313+for line in groups[0]:
1414+ x, y = [int(x) for x in line.split(',')]
1515+ DOTS[Point(x, y)] = '#'
1616+1717+for line in groups[1]:
1818+ axis, n = line.split()[2].split('=')
1919+ FOLDS.append((axis, int(n)))
2020+2121+for i, (axis, n) in enumerate(FOLDS):
2222+ new_dots = {}
2323+2424+ for p in DOTS:
2525+ if axis == 'x':
2626+ if p.x < n:
2727+ new_dots[p] = '#'
2828+ else:
2929+ dx = abs(n - p.x)
3030+ nx = n - dx
3131+ new_dots[Point(nx, p.y)] = '#'
3232+ else:
3333+ if p.y < n:
3434+ new_dots[p] = '#'
3535+ else:
3636+ dy = abs(n - p.y)
3737+ ny = n - dy
3838+ new_dots[Point(p.x, ny)] = '#'
3939+4040+ DOTS = new_dots
4141+4242+ if i == 0:
4343+ print "Part 1:", len(DOTS)
4444+4545+print "Part 2:\n", '\n'.join(print_grid(DOTS, quiet=True))