diff --git a/13/main.go b/13/main.go index 13cfc71..c04d61f 100644 --- a/13/main.go +++ b/13/main.go @@ -72,14 +72,17 @@ func partTwo() { } } - // walking the list works fine for the small test inputs but takes far too long on the real schedule t := float64(0) + offset := buses[0].route for { loop: - t = t + buses[0].route + t = t + offset + offset = 1 for i := range buses { if math.Remainder(t+buses[i].offset, buses[i].route) != 0 { goto loop + } else { + offset = offset * buses[i].route } } break