The Empire strikes back

Report a typo

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.

Sample Input 1:

Ford-11 Bismarck-20 Titanic-34 HMS-44

Sample 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

}
___

Create a free account to access the full topic