The Empire strikes back

Report a typo

The Resistance is organizing ships to confront the Empire. R2D2 has a list with all the ships. The Resistance will attack only with the ships whose ammunition is greater than a given parameter ammunitionLimit. Please help R2D2 to get the list of names of these ships using the infix operator battle.

println(listOfShip battle 50)

Sample Input 1:

Ford-11 Bismarck-200 Titanic-340 HMS-44

Sample Output 1:

[Bismarck, Titanic]
Write a program in Kotlin
// complete the definition
/*?*/.battle(ammunitionLimit: Int): List<String> {
// write the rest of the code
}

data class Ship(val name: String, val ammunition: Int)
___

Create a free account to access the full topic