import pandas as pd
import numpy as np
seq = pd.read_csv("H:/python_jiggering/logs/aoc_2017/d5_input.txt", header = None)
seq = np.array(seq[0])
seq_len = len(seq)
start_loc = 0
loc = 0
next_loc = start_loc + seq[start_loc]
moves = 0
while next_loc >= 0 and next_loc <= (seq_len -1):
moves += 1
seq[loc] += 1
loc = next_loc
next_loc = loc + seq[loc]
moves + 1
Part 2 seems pretty simple, they just want us to change the rules to if the offset is 3 or more, decrease by 1:
seq = pd.read_csv("H:/python_jiggering/logs/aoc_2017/d5_input.txt", header = None)
seq = np.array(seq[0])
seq_len = len(seq)
loc = 0
next_loc = start_loc + seq[start_loc]
moves = 0
while next_loc >= 0 and next_loc <= (seq_len -1):
moves += 1
seq[loc] += (-1) ** (seq[loc] >= 3)
loc = next_loc
next_loc = loc + seq[loc]
moves + 1