Course of Raku / Essentials / Positional data types / Exercises

Traffic lights

Problem

The traffic light changes its colour every second. When it was first turned on, it started as yellow. Then, every second the colour changed 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

See the solution

Course navigation

Typed variables / Allomorphs   |   Associative data types

Translations of this page: EnglishDeutschEspañolItalianoLatviešuNederlandsБългарскиРусскийУкраїнська