Example #1
0
    95
    102
    117
    150
    182
    127
    219
    299
    277
    309
    576
    """
).strip()


if __name__ == "__main__":
    advent.setup()
    advent.test(
        functools.partial(main, preamble_length=5),
        advent.TestCase(
            input=SAMPLE_INPUT,
            expected_part_1=127,
            expected_part_2=62,
        ),
    )

    advent.execute(
        main,
        Path(__file__).parent.absolute() / "input.txt",
    )
Example #2
0
def download_input_data():
    global fin
    global lines
    advent.setup(2020, 2, dry_run=False)
    fin = advent.get_input()
    lines = get_lines(fin.readlines())
Example #3
0
def download_input_data():
    global fin
    global nums
    advent.setup(2020, 1, dry_run=False)
    fin = advent.get_input()
    nums = list(map(int, fin.readlines()))
Example #4
0
	jump_ahead_num = first
	t = first

	for line in rest:
		print(f"t {t}, jump ahead num {jump_ahead_num}")
		# input('press enter to continue')
		t = find_next_alignment(line, buses[line], jump_ahead_num, t)
		# jump_ahead_num = lcm(jump_ahead_num, line)
		jump_ahead_num *= line  # this works bc all numbers are prime
	return t



def find_next_alignment(current_num, offset, jump_ahead_num, t):
	print('finding next alignment')
	while True:
		

		# loop by lcm 
		if (t + offset) % current_num == 0:
			return t
		else:
			t += jump_ahead_num


if __name__ == "__main__":
	buses, _ = advent.process("input.txt", part2=True)
	buses = advent.setup(buses)
	print(f"the answer {loop_quickly(buses)}")