Application

Report a typo

The Resistance is organizing ships to confront the Empire. R2D2, a droid loyal to Luke Skywalker, using its AI must obtain a summary – the number of ships with different amounts of ammunition (X), the sum of all ammunition assigned to the squadron (Y), and the average ammunition (Z) of each squadron sent to fight against the Empire. You must present the result as "X:Y:Z"

Sample Input 1:

HMS-10 USS-20 BMS-10 BMS-15 USS-100

Sample Output 1:

4:155:31.0
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