+/AoC
advent of code
git clone https://git.julia.blue/+/AoC
f77d550
master
1points = [] 2folds = [] 3with open ("input" )as f : 4done = False 5for line in f : 6temp = line .strip () 7if not done and temp : 8a ,b = temp .split ("," ) 9points .append ((int (a ),int (b ))) 10else : 11if not done : 12done = True 13continue 14axis ,num = line .split ("=" ) 15folds .append ((axis [- 1 ],int (num ))) 16 17 18def fold (pts ,fold ): 19axis ,pos = fold 20new = [] 21for p in pts : 22x ,y = p 23if axis == "y" and y > pos : 24y = pos - (y - pos ) 25elif axis == "x" and x > pos : 26x = pos - (x - pos ) 27new .append ((x ,y )) 28return new 29 30 31len (set (fold (points ,folds [0 ])))) 32 33for f in folds : 34points = fold (points ,f ) 35 36for y in range (10 ): 37"" .join ("X" if (x ,y )in points else " " for x in range (50 )))