from aoc.input import get_input import math import copy import itertools import time import collections import re from aoc.partselector import part_one, part_two import functools def pw(line): return line.strip().split(',') def p1(): inp = get_input(pw) start = int(inp[0][0]) busses = inp[1] rb = [] for b in busses: if b != 'x': rb.append(b) print(rb) m = 0 for x in rb: x = int(x) if m < ((start % x)+x): print (x, start % x) m = (start % x)+x return inp def p2(): inp = get_input(pw) busses = inp[1] rb = [] mods = {} for b in enumerate(busses): if b[1] != 'x': bn = int(b[1]) rb.append(bn) mods[bn] = (- b[0]) % bn r = rb[0] val = mods[r] for b in rb[1:]: print(r, b) while val % b != mods[b]: val += r r *= b print(val) return val return 0 result1 = None if part_one(): start = time.time() result1 = p1() print(round(1000*(time.time() - start), 2), 'ms') if part_two(): start = time.time() p2() print(round(1000*(time.time() - start), 2), 'ms')