The Resistance is organizing ships to confront the Empire. R2D2 has a list with all ships. The Resistance will attack only with the ships whose ammunition is greater than 20. Please help R2D2 to get the list of names of these ships in alphabetical order.
Sequences
The Empire strikes back
Report a typo
Sample Input 1:
Ford-11 Bismarck-20 Titanic-34 HMS-44Sample Output 1:
[HMS, Titanic]Write a program in Kotlin
class Ship(val name: String, val ammunition: Int) {
override fun toString(): String {
return "$name-$ammunition"
}
}
fun main() {
val ships = readln().split(" ")
val shipsSequence = ships.map { Ship(it.split("-")[0], it.split("-")[1].toInt()) }.asSequence()
// write your code here
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.