The Resistance is organizing ships to confront the Empire. R2D2 has a list with the ships. The droid should get the last ship in the strike group whose ammunition is greater than 200. You must help R2D2 organize defense against the empire and code the droid's AI to print only the name of the ship or "No ship found" if it does not exist.
Retrieve single element
The Empire strikes back
Report a typo
Sample Input 1:
XWing-100 YWing-200 TWing-50 TIEFighter-300Sample Output 1:
TIEFighterWrite a program in Kotlin
data class Ship(val name: String, val ammunition: Int)
fun main() {
val ships = readln().split(" ")
val shipsList = ships.map { Ship(it.split("-")[0], it.split("-")[1].toInt()) }
// 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.