Can anyone please help me with the CMU CS Academy Unit 2, 2.4 exercise "Toilet Paper"?

I will award Brainliest to whoever answers as soon as possible.

Thank you!

(AP Computer Science Principles question)