value = int(value) if instruction == 'acc': acc += value i += 1 elif instruction == 'jmp': i += value else: i += 1 if i >= len(lines): print(acc) return True else: return False lines = read_file("input.txt") indices_treated = set() i = 0 acc = 0 while i not in indices_treated and i < len(lines): indices_treated.add(i) instruction, value = lines[i].split(' ') value = int(value) if instruction == 'acc': acc += value i += 1 elif instruction == 'jmp': # we try changing to nope if check_finish(i + 1, acc, indices_treated): break else:
def parse(filename: str) -> Tuple[int, ...]: data = utils.read_file(filename) return tuple(int(x) for x in data.strip().split(","))
def get_letters(filepath): data = utils.read_file(filepath) for char in data: yield char
from aoc import utils lines = utils.read_file("input.txt") for i in lines: i = int(i) for j in lines: j = int(j) for k in lines: k = int(k) if not i ==j and not i==k and not k==j and i + j+k == 2020: print(i*j*k)