C++20 sections · 1024 units
Open in Course

Problem - Xenia and Ringroad

Planning a route

You're given a ring road with nn houses numbered 11 to nn in clockwise order. Xenia starts at house 11 and needs to visit mm specific houses in a particular order. Each move from one house to the next clockwise neighbor takes 11 minute.

Your task: calculate the minimum time needed to visit all required houses in the given order. This tests your understanding of modular arithmetic and how to handle circular structures with vectors.

Before reading further, think: what happens when you need to go from house 55 to house 22 on a ring road with 77 houses? How many moves does that take?