Application

Report a typo

The Resistance is organizing ships to confront the Empire. R2D2, a droid loyal to Luke Skywalker, must order the ships based on their ammunition, knowing that the ships with less ammunition will enter the battle first.
Can you help him get the list of ships for the fight?

Sample Input 1:

HMS-100 USS-200 BMS-50 BMS-150 USS-10

Sample Output 1:

[Ship(name=USS, ammunition=10), Ship(name=BMS, ammunition=50), Ship(name=HMS, ammunition=100), Ship(name=BMS, ammunition=150), Ship(name=USS, ammunition=200)]
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)
}
___

Create a free account to access the full topic