Re:Advent of Code 2021
by maximus-decimus on Tuesday December 07, 2021 @08:11PM
(#29480246)
it's funny to me how your problem is literally an applied fizz buzz.
But then again people have a much harder time applying concept they know to given situations than if they're told directly to do something.
Two buses make different circular routes from the same depot. One bus takes 3 hours to do a loop, the other takes 5. At what times from the start of the day will both buses be at the depot at the same time?
you could write a loop like this:
which if you run, you'd see: and even if you knew nothing about math, you could see that and think, oh, so they just meet every 15, which happens to be 3 times 5... You don't need to count up one at a time and check remainders, you can just increment by 15 and get the exact same result.. That's more or less what I did when I solved it.. saw how the problem simplified to finding the common multiples of numbers, which when they are prime is just the product. apply this process iteratively and you have the solution.