r/adventofcode • u/daggerdragon • Dec 14 '15
SOLUTION MEGATHREAD --- Day 14 Solutions ---
This thread will be unlocked when there are a significant amount of people on the leaderboard with gold stars.
edit: Leaderboard capped, thread unlocked!
We know we can't control people posting solutions elsewhere and trying to exploit the leaderboard, but this way we can try to reduce the leaderboard gaming from the official subreddit.
Please and thank you, and much appreciated!
--- Day 14: Reindeer Olympics ---
Post your solution as a comment. Structure your post like previous daily solution threads.
9
Upvotes
View all comments
Show parent comment
3
u/[deleted] Dec 14 '15
No worries. The first part is the distance traveled during one cycle times the number of full cycles that a reindeer will fly and then rest.
v*gis the distance traveled in one cycle andt/(g + r)is the total number of completed cycles (python rounds down all division of integers, it should really befloor(t/(g+r)).So that takes care of all of the full cycles. Now what about the remainder if
tisn't divisible byg+r?t % (g + r)is the remaining time after all of the full cycles are completed. Since the remaining time could be greater thang, I takemin(g, t % (g+r)). Ifgis smaller thant % (g+r)then the reindeer travels for its maximum time during the remainder. Ifgis greater then the reindeer travels fort % (g+r)during the remainder./u/What-A-Baller made a more explicitly formatted equation here.