Knapsack problem/Unbounded: Difference between revisions
Content added Content deleted
(Contribution reconstruction due to vandalism.) |
|||
Line 3,494: | Line 3,494: | ||
MILP solver output: |
MILP solver output: |
||
<pre> |
<pre>TotalValue |
||
TotalValue |
|||
54500 |
54500 |
||
Line 3,527: | Line 3,526: | ||
gold (bars) 11 |
gold (bars) 11 |
||
ichor (ampules of) 0 |
ichor (ampules of) 0 |
||
panacea (vials of) 9 |
panacea (vials of) 9 </pre> |
||
</pre> |
|||
=={{header|Scala}}== |
=={{header|Scala}}== |
||
===Functional approach (Tail recursive)=== |
===Functional approach (Tail recursive)=== |
||
<lang scala>import scala.annotation.tailrec |
<lang scala>import scala.annotation.tailrec |
||
Line 3,574: | Line 3,569: | ||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
[panacea: 0, ichor: 15, gold: 11 | value: 54500, weight: 25.0, volume: 0.247] |
[panacea: 0, ichor: 15, gold: 11 | value: 54500, weight: 25.0, volume: 0.247] |
||
Line 3,581: | Line 3,575: | ||
[panacea: 9, ichor: 0, gold: 11 | value: 54500, weight: 24.7, volume: 0.247] |
[panacea: 9, ichor: 0, gold: 11 | value: 54500, weight: 24.7, volume: 0.247] |
||
</pre> |
</pre> |
||
{{Out}}See it in running in your browser by [https://scalafiddle.io/sf/1fRBQs5/2 ScalaFiddle (JavaScript)] or by [https://scastie.scala-lang.org/S4oGElcwQkCMesfuSRKfkw Scastie (JVM)]. |
|||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
<lang seed7>$ include "seed7_05.s7i"; |
<lang seed7>$ include "seed7_05.s7i"; |