The Resistance is organizing ships to confront the Empire. R2D2, a droid loyal to Luke Skywalker, using its AI must select the ship for combat knowing that the one with the least ammunition will always be selected first.
Aggregate operations on collections
The Empire strikes back
Report a typo
Sample Input 1:
HMS-100 USS-200 BMS-50 BMS-150 USS-10Sample Output 1:
Ship(name=USS, ammunition=10)Write 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
val res =
println(res)
}
___
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.