-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday13.krk
37 lines (30 loc) · 1.04 KB
/
day13.krk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env kuroko
'''
Template
'''
import fileio
import kuroko
let data
with fileio.open(kuroko.argv[1] if len(kuroko.argv) > 1 else kuroko.argv[0].replace('.krk','.txt'),'r') as f:
data = f.readlines()
let lines = [line.strip() for line in data]
let inputs = []
let insts = []
for line in lines:
if not line: break
inputs.append([int(x) for x in line.split(',')])
for line in lines:
if not line.startswith('fold'): continue
insts.append((lambda x,y: (x,int(y)))(*line.split('along ')[1].split('=')))
def dump(inputs):
let unique = {tuple(dot): True for dot in inputs}
let width, height = max(x for x,y in unique.keys()) + 1, max(y for x,y in unique.keys()) + 1
if width < 300:
print('\n'.join([''.join(['█' if (x,y) in unique else ' ' for x in range(width)]) for y in range(height)]))
print(len(unique))
for axis, at in insts:
let ind = 1 if axis == 'y' else 0
for d in range(len(inputs)):
if inputs[d][ind] >= at:
inputs[d][ind] = at - (inputs[d][ind] - at)
dump(inputs)