Solving coin problems: Difference between revisions

m
→‎{{header|Phix}}: added example comment
m (→‎{{header|Phix}}: added example comment)
Line 1,339:
-- Based on https://mathcs.clarku.edu/~djoyce/ma105/simultaneous.html
-- aka the ancient Chinese Jiuzhang suanshu ~100 B.C. (!!)
--
-- Example (ignoring n, which is solely for output):
-- rules = {{18,1,1},{38,1,5}}, ie 18==p+n, 38==p+5*n
-- unknowns = {"pennies","nickels"}
-- expected = "pennies = 13, nickels = 5"
--
-- In the elimination phase, both p have multipliers of 1, so we can
-- ignore those two sq_mul and just do (38=p+5n)-(18=p+n)==>(20=4n).
-- Obviously therefore n is 5 and substituting backwards p is 13.
--
string res
Line 1,426 ⟶ 1,435:
integer k = find(false,vused)
if k then ?{"unused vocab",vocab[k]} end if</lang>
{{out}}
You just gotta love this Pidgin English! The problem numbering system used below is mine alone.<br>
I was slightly unsure whether to interpolate these q&a outputs, but I think the separation chosen has its own merits.<br>
The structures/equations of part 2 are completely unreadable at first, but quite simple really.
{{out}}
<pre>
24 puzzles:
7,804

edits