#!/bin/python3 import sys,re from pprint import pprint input_f = 'input' def list2int(x): return list(map(int, x)) part = 1 ######################################### # # # Part 1 # # # ######################################### if part == 1: size = 256 lengths = [] skip = 0 numbers = [] pos = 0 for i in range(0,size): numbers.append(i) with open(input_f) as file: for line in file: lengths = list2int(line.rsplit()[0].split(',')) for ldx, length in enumerate(lengths): sub = [numbers[(pos + i) % len(numbers)] for i in range(length)] rev = sub[::-1] for i in range(length): numbers[(pos + i) % len(numbers)] = rev[i] pos += (length+skip) pos = pos % len(numbers) skip += 1 print(numbers[0]*numbers[1]) ######################################### # # # Part 2 # # # ######################################### if part == 2: exit()