Parse Traffic Light Signal Sequence
Parse Traffic Light Signal Sequence
EasyStrings0% accepted
Bangalore's smart traffic system uses codes like 'R-30-G-25-Y-5' representing color-duration pairs. Engineer Arjun validates that only valid colors appear in correct sequence.
Approach
Parse a traffic signal sequence of color-duration pairs separated by hyphens and verify only valid colors (R, G, Y) appear with positive integer durations.
Input
R-30-G-25-Y-5
Output
true
More Strings problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards