4. Task and order of execution / Завдання та порядок виконання
Source of tasks. The tasks below are taken exactly from the assignment “State Machine”. Implement a state machine that finds numbers in a string; the input/output examples are authoritative. The same input string is used for every task.
Order of execution
Implement the tasks in order — each extends the previous state machine with more states. Your score corresponds to the most difficult task you complete correctly.
Easy Task (60–74 points)
Find all digits in the string.
- Input:
adfvq3414fn.f143.31f-113.112vwe - Output:
341414331113112
Mid Task (75–80)
Find all integers in the string.
- Input:
adfvq3414fn.f143.31f-113.112vwe - Output:
[3414, 143, 31, 113, 112]
Mid Task (81–89)
Find all positive rational numbers in the string.
- Input:
adfvq3414fn.f143.31f-113.112vwe - Output:
[3414, 143.31, 113.112]
Hard Task (90–100)
Find all rational numbers in the string.
- Input:
adfvq3414fn.f143.31f-113.112vwe - Output:
[3414, 143.31, -113.112]