October 2025
Intermediate to advanced
100 pages
2h 27m
English
| Puzzle 15 | End of the Line |
| | val numbers = sequence { |
| | try { |
| | for (i in 1..100) yield(i) |
| | } finally { |
| | println("Finished generating numbers") |
| | } |
| | } |
| | |
| | fun main() { |
| | for (n in numbers) { |
| | println("The next number is $n") |
| | if (n >= 5) break |
| | } |
| | println("Finished printing numbers") |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess the output (or error) before moving to the next page. |
The program displays the following output:
| | The next number is 1 |
| | The next number is 2 |
| | The next number is 3 |
| | The next number is 4 |
| | The next number is 5 |
| | Finished printing ... |
Read now
Unlock full access