Count the coins/0-1: Difference between revisions

m
→‎{{header|Phix}}: reworded comments
m (→‎{{header|Pascal}}: added checking all weights not taking order into account)
m (→‎{{header|Phix}}: reworded comments)
Line 329:
=={{header|Phix}}==
=== sane way ===
ThisIn the second test, this counts [1,2,3] as one way, notto countingget [in6, 2ndnot test]counting the other [1,2,3] or the other [1,2,3] or the other [1,2,3].
<lang Phix>function choices(sequence coins, integer tgt, cdx=1)
integer count = 0
Line 353:
</pre>
=== silly way ===
ThisIn the second test, this counts [1,2,3] as four ways to get 6, since [in 2nd test] there are two 1s and two 3s... ("order unimportant")
<lang Phix>function silly(sequence coins, integer tgt, cdx=1)
integer count = 0
Line 374:
</pre>
=== very silly way ===
ThisIn the second test, this counts [1,2,3] as 24 ways to get 6, from 2 1s, 2 3s [in 2nd test], and 6 ways to order them ("order important")
<lang Phix>function very_silly(sequence coins, integer tgt, cdx=1, taken=0)
integer count = 0
7,804

edits