Knapsack problem/Continuous: Difference between revisions
Content added Content deleted
Catskill549 (talk | contribs) |
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
||
Line 1,869: | Line 1,869: | ||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
<lang scala>// version 1.1. |
<lang scala>// version 1.1.2 |
||
data class Item(val name: String, val weight: Double, val value: Double) |
data class Item(val name: String, val weight: Double, val value: Double) |
||
Line 1,882: | Line 1,882: | ||
Item("welt", 3.7, 67.0), |
Item("welt", 3.7, 67.0), |
||
Item("salami", 3.0, 95.0), |
Item("salami", 3.0, 95.0), |
||
Item("sausage", 5.9, 98.0) |
Item("sausage", 5.9, 98.0) |
||
) |
) |
||
Line 1,900: | Line 1,900: | ||
sumValue += item.value |
sumValue += item.value |
||
print("${item.name.padEnd(11)} ${"%3.1f".format(item.weight)} ${"%5.2f".format(item.value)}") |
print("${item.name.padEnd(11)} ${"%3.1f".format(item.weight)} ${"%5.2f".format(item.value)}") |
||
println(" 100.00") |
println(" 100.00") |
||
} |
} |
||
else { |
else { |