advent-of-code

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit ef09cc1d5d4c66b3f191bbf82fec1f9199be63ee
parent 96c4e55da57974d9961956dfb7556c22cfc11d2d
Author: mpizzzle <michael.770211@gmail.com>
Date:   Sun, 10 Dec 2017 16:03:40 +0000

puzzle 10 part 1 complete

Diffstat:
Afiles/puzzle10.txt | 1+
Apuzzle10.py | 14++++++++++++++
2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/files/puzzle10.txt b/files/puzzle10.txt @@ -0,0 +1 @@ +106,118,236,1,130,0,235,254,59,205,2,87,129,25,255,118 diff --git a/puzzle10.py b/puzzle10.py @@ -0,0 +1,14 @@ +with open('files/puzzle10.txt') as f: + puzzle_input = [int(c) for c in f.read().split(',')] + +my_list = [i for i in range(256)] +skip, pos = 0, 0 + +for length in puzzle_input: + twist = reversed([my_list[i % len(my_list)] for i in range(pos, pos + length)]) + for i, t in zip(range(pos, pos + length), twist): + my_list[i % len(my_list)] = t + pos += length + skip + skip += 1 + +print my_list[0] * my_list[1]