+/AoC
advent of code
git clone https://git.julia.blue/+/AoC
38c0746
master
1with open ("input.txt" )as f : 2raw = f .read ().strip () 3inputs = map (int ,raw .split (',' )) 4 5length = 256 6knot = range (length ) 7skip = 0 8current = 0 9 10for i in inputs : 11for j in range (i // 2 ): 12front = (current + j )% length 13back = (current + i - j - 1 )% length 14knot [front ],knot [back ]= knot [back ],knot [front ] 15current += i + skip 16skip += 1 17 18"Part 1:" ,knot [0 ]* knot [1 ] 19 20knot = range (length ) 21skip = 0 22current = 0 23for n in range (64 ): 24for i in map (ord ,raw )+ [17 ,31 ,73 ,47 ,23 ]: 25for j in range (i // 2 ): 26front = (current + j )% length 27back = (current + i - j - 1 )% length 28knot [front ],knot [back ]= knot [back ],knot [front ] 29current += i + skip 30skip += 1 31 32dense = [reduce (lambda x ,y :x ^ y ,knot [i * 16 :(i + 1 )* 16 ])for i in range (16 )] 33 34"Part 2:" ,'' .join (hex (i )[2 :].zfill (2 )for i in dense )