Hey, it’s Théo from ! Here’s this week’s challenge. Have fun solving it :)
Imagine you’re in charge of managing routing at a data center for a company called Rainforest. Specifically, you’re in charge of ensuring communications between the four availability zones A, B, C & D at your center are fast.
Until today, you only had four cables (shown in black) connecting A to B, A to D, B to C and C to D. Although the exact latencies — that is, the time it takes for a signal to travel from one end of a cable to the other — were never documented, you do know that routing from A to D via B and C (red path) takes 113 milliseconds, and routing from A to B via D and C (green path) takes 127 milliseconds.
But now, a fancy new optical cable has been installed between B and D, and you know its latency is 11 milliseconds (blue cable).
Previously, you had setup your system so that requests from A to D used the cable linking them directly, since it was calculated to be faster than going from A to D via B and C. Yet again, nobody documented those calculations and you must do it all over.
With that new low-latency cable you’ve got, you’re wondering if the direct A-D cable is still the shortest path, or if it would make sense to go from A to D via B to leverage this new cable.
Your task is to calculate which route is faster: Taking the direct A-D cable, or routing from A to D via B (using the A–B cable together with the new B–D cable)?
Until next week !