My julia solutions for Advent of Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
509 B

using AdventOfCode
using Mods
t_str, buses_str = readlines("2020/data/day_13.txt")
time = parse(Int, t_str)
buses = map(x->x=="x" ? nothing : parse(Int, x), split(buses_str, ','))
function part_1()
wait, bus = min(map(x->(x*ceil(time / x), x), filter(!isnothing, buses))...)
(wait - time) * bus
@info part_1()
function part_2()
mods = map(k->Mod{buses[k]}(-(k-1)), filter(k->!isnothing(buses[k]), keys(buses)))
@info part_2()