October 2025
Intermediate to advanced
100 pages
2h 27m
English
| Puzzle 17 | Don’t Bet on It |
| | data class Animal(val name: String, val speed: Int) |
| | |
| | fun race(racer1: Animal, racer2: Animal) { |
| | if (racer1.speed > racer2.speed) { |
| | racer1.name |
| | } else if (racer2.speed > racer1.speed) { |
| | racer2.name |
| | } else { |
| | null |
| | }.let { winner -> |
| | if (winner != null) println("$winner wins!") else println("It's a draw") |
| | } |
| | } |
| | |
| | fun main() { |
| | race(Animal("Hare", speed = 100), Animal("Tortoise", speed = 10)) |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess the output (or error) before moving to the next page. |
The program completes ...
Read now
Unlock full access