345. Traffic Light Colour
EasyModular Arithmetic
A light shows GREEN for g seconds, YELLOW for y seconds, then RED for r seconds, repeating from time 0. Print its colour at time t.
Input format
A single line: g y r t
Output format
GREEN, YELLOW or RED
Example 1
Input
30 5 25 0
Output
GREEN
Example 2
Input
30 5 25 32
Output
YELLOW
Constraints
1 ≤ g, y, r ≤ 10⁶ 0 ≤ t ≤ 10¹⁸
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…