Course of Raku / Essentials / More about types / Positional data types / Exercises
Traffic lights
Problem
The traffic light changes its colour every second. When it is first turned on, it starts as yellow. Then, every second the colour changes in the order yellow — red — yellow — green and the cycle starts over.
Write a program that prints the state of the traffic lights on the 51st, 102nd and 305th second, assuming that the colour on the 1st second is red.
Example
The program should print three numbers on separate lines:
$ raku traffic-lights.raku
...
...
...Solution
Course navigation
← Solution: Square and cube | Solution: Traffic lights →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська