Post Reply 
Vietnamese snake puzzle - Closed
05-21-2015, 01:51 PM (This post was last modified: 05-21-2015 01:52 PM by Tugdual.)
Post: #21
RE: Vietnamese snake puzzle - Closed
(05-21-2015 01:18 PM)fhub Wrote:  
(05-21-2015 11:53 AM)Tugdual Wrote:  I think there are 128 in my list and this is what Haskell returned.
Do you expect more?
Yes, I do expect more. Wink

Your list is missing 8 additional solutions (due to rounding errors), there are 136 solutions in total - here the missing 8:
183745269
183745629
269851473
269851743
783145269
783145629
869251473
869251743

If you rewrite your equation (avoiding the 2 divisions by multiplying with the 2 denominators), then your program will give you all 136 solutions.
Edit: Or change the test to something like abs(expr-66)<1e-3 ...

Franz
Thanks! I'm getting used to the 50g CAS and tend to forget about wandering floats.
Code:
[x | x <- permutations [1..9], abs(x!!0+13*x!!1/x!!2+x!!3+12*x!!4-x!!5-11+x!!6*x!!7/x!!8-10-66) < 1E-6]
and do get the 136 answers (a bit slower by the way... but still pretty quick).
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Vietnamese snake puzzle - Dave Britten - 05-20-2015, 11:27 AM
RE: Vietnamese snake puzzle - Gerald H - 05-20-2015, 11:33 AM
RE: Vietnamese snake puzzle - Gerald H - 05-20-2015, 12:58 PM
RE: Vietnamese snake puzzle - Closed - Tugdual - 05-21-2015 01:51 PM



User(s) browsing this thread: 2 Guest(s)