October 2025
Intermediate to advanced
100 pages
2h 27m
English
| Puzzle 22 | Inside, Outside |
| | data class Point(val x: Int, val y: Int) |
| | |
| | fun createRoutePlan() = buildList { |
| | var x = 1 |
| | for (y in 1..3) { |
| | add { Point(x, y) } |
| | x++ |
| | } |
| | } |
| | |
| | fun main() { |
| | for (nextLocation in createRoutePlan()) { |
| | println("Robot is moving to: " + nextLocation()) |
| | } |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess the output (or error) before moving to the next page. |
The program displays the following output:
| | Robot is moving to: Point(x=4, y=1) |
| | Robot is moving to: Point(x=4, y=2) |
| | Robot is moving to: Point(x=4, y=3) |
Read now
Unlock full access