Vietnamese snake puzzle - Closed - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Vietnamese snake puzzle - Closed (/thread-3920.html) Pages: 1 2 Vietnamese snake puzzle - Closed - Gerald H - 05-20-2015 09:37 AM Order of operations argument or find a solution? http://www.theguardian.com/science/alexs-adventures-in-numberland/2015/may/20/can-you-do-the-maths-puzzle-for-vietnamese-eight-year-olds-that-has-stumped-parents-and-teachers RE: Vietnamese snake puzzle - Dave Britten - 05-20-2015 11:27 AM (05-20-2015 09:37 AM)Gerald H Wrote:  Order of operations argument or find a solution? http://www.theguardian.com/science/alexs-adventures-in-numberland/2015/may/20/can-you-do-the-maths-puzzle-for-vietnamese-eight-year-olds-that-has-stumped-parents-and-teachers Quote:multiply first, then division Let's go with argument first, that's more important than solutions. RE: Vietnamese snake puzzle - Gerald H - 05-20-2015 11:33 AM Pedantic - me? Order of operations sort of defined in Guardian text. Two types of action - quibble or solve. RE: Vietnamese snake puzzle - Gerald H - 05-20-2015 12:58 PM Solvers win - answer found. Quibblers remain confounded. RE: Vietnamese snake puzzle - Closed - Dave Britten - 05-20-2015 01:24 PM Let's assume the 10 variables are named A through I, and that we're doing the standard order of operations here (multiplication and division together from left to right, then addition and subtraction together from left to right). If we assume that non-integer intermediate results are allowable (e.g. G * H / I can be 1 * 4 / 8), then there are 120 valid solutions (verified via brute force with Heap's algorithm in C# - no, I'm not going to generate 362,880 permutations with a 9-level recursive algorithm on my 48*). If we stipulate that 13 * B / C and G * H / I must have integer results, then there are 20 valid solutions. *Although, there is a 3-day weekend coming up... RE: Vietnamese snake puzzle - Closed - Gerald H - 05-20-2015 01:30 PM Pedantic - me? A to I traditionally 9 letters & same number of variables. RE: Vietnamese snake puzzle - Closed - Dave Britten - 05-20-2015 01:35 PM (05-20-2015 01:30 PM)Gerald H Wrote:  Pedantic - me? A to I traditionally 9 letters & same number of variables. Er, yeah, 9 variables, not 10. Us CS guys and our off-by-one errors... RE: Vietnamese snake puzzle - Closed - Gilles - 05-20-2015 09:01 PM I wrote a UserRPL program (HP50G) for this. With the emulator the first solution is found in few minutes. Non-integer intermediate results are allowed. Program still running. 22 solutions found for now. RE: Vietnamese snake puzzle - Closed - Gerson W. Barbosa - 05-21-2015 04:04 AM I've found one solution using paper and pencil only, but I'm not pleased with my work. I assumed all intermediate results are integer. This implies c = 1, because 13 is prime. I didn't figure out any other way than atributing values to three variables (i, b and e) and changing them sequentially as they proved to be impossible. It took no more than an hour and a sheet of paper to find the solution, but that would be too much during an examination though. No spoiler: a.b.d.e = 120 f.g.h.i = 3024 RE: Vietnamese snake puzzle - Closed - Gerald H - 05-21-2015 05:30 AM (05-21-2015 04:04 AM)Gerson W. Barbosa Wrote:  I've found one solution using paper and pencil only, but I'm not pleased with my work. I assumed all intermediate results are integer. This implies c = 1, because 13 is prime. I didn't figure out any other way than atributing values to three variables (i, b and e) and changing them sequentially as they proved to be impossible. It took no more than an hour and a sheet of paper to find the solution, but that would be too much during an examination though. No spoiler: a.b.d.e = 120 f.g.h.i = 3024 Factors check out as a possibly good solution. RE: Vietnamese snake puzzle - Closed - Tugdual - 05-21-2015 08:12 AM Since I'm in Haskell at the moment, I gave it a go, it is quite a simple exercise. For what it matters, I found 128 solutions instantly... wow. Haskell code Code: ```import Data.List [x | x <- permutations [1..9], (x!!0+13*x!!1/x!!2+x!!3+12*x!!4-x!!5-11+x!!6*x!!7/x!!8-10)==66]``` Solutions Code: ``` 126478539 426178539 126478359 426178359 296351478 396251478 132956478 932156478 714965328 914765328 734165928 734165298 134765928 134765298 314279568 214379568 796152438 196752438 912567438 512967438 714965238 914765238 236179458 136279458 314279658 214379658 296351748 236179548 136279548 396251748 132956748 932156748 796152348 196752348 912567348 512967348 948567132 948567312 548967132 548967312 496158732 196458732 764859132 764859312 864759132 864759312 364958172 364958712 964358172 964358712 196458372 496158372 286941753 986241753 286941573 986241573 139478256 139478526 324851976 324851796 132458976 132458796 248179356 148279356 439178256 439178526 824351976 824351796 432158976 432158796 248179536 148279536 941527836 941527386 321547986 321547896 352148976 352148796 152348976 152348796 521347986 521347896 153942876 953142876 153942786 953142786 752849136 752849316 852749136 852749316 852147936 852147396 152847936 152847396 541927836 541927386 328651974 328651794 931625874 931625784 628351974 628351794 631925874 631925784 693521874 693521784 928765134 928765314 728965134 728965314 732859164 732859614 731526984 731526894 832759164 832759614 892315764 392815764 892315674 392815674 872539164 872539614 572839164 572839614 531726984 531726894 593621874 593621784``` RE: Vietnamese snake puzzle - Closed - Gerald H - 05-21-2015 08:41 AM Do you, Tugdual, claim your list of solutions is exhaustive? RE: Vietnamese snake puzzle - Closed - Tugdual - 05-21-2015 10:51 AM (05-21-2015 08:41 AM)Gerald H Wrote:  Do you, Tugdual, claim your list of solutions is exhaustive? Yes I would think so unless my Haskell code is wrong but I checked a few combinations and they look good. RE: Vietnamese snake puzzle - Closed - Gerald H - 05-21-2015 11:21 AM (05-21-2015 10:51 AM)Tugdual Wrote:   (05-21-2015 08:41 AM)Gerald H Wrote:  Do you, Tugdual, claim your list of solutions is exhaustive? Yes I would think so unless my Haskell code is wrong but I checked a few combinations and they look good. I only see 127 solutions? RE: Vietnamese snake puzzle - Closed - Tugdual - 05-21-2015 11:53 AM (05-21-2015 11:21 AM)Gerald H Wrote:   (05-21-2015 10:51 AM)Tugdual Wrote:  Yes I would think so unless my Haskell code is wrong but I checked a few combinations and they look good. I only see 127 solutions? I think there are 128 in my list and this is what Haskell returned. Do you expect more? RE: Vietnamese snake puzzle - Closed - Gerald H - 05-21-2015 12:02 PM I beg your pardon, Tugdual, I miscounted. I only expected one solution & was happy when I found one. Bravo on your quick research. RE: Vietnamese snake puzzle - Closed - Gerson W. Barbosa - 05-21-2015 12:19 PM (05-21-2015 05:30 AM)Gerald H Wrote:   (05-21-2015 04:04 AM)Gerson W. Barbosa Wrote:  a.b.d.e = 120 f.g.h.i = 3024 Factors check out as a possibly good solution. 321547986 and all valid commutations thereof. RE: Vietnamese snake puzzle - Closed - Tugdual - 05-21-2015 12:29 PM (05-21-2015 12:02 PM)Gerald H Wrote:  I beg your pardon, Tugdual, I miscounted. I only expected one solution & was happy when I found one. Bravo on your quick research. Thanks but no glory, Haskell is quite amazing for that sort of brute force... Now I guess the real fun to stick on the forum topic would be to find a clever solution to do that with a simple calculator. RE: Vietnamese snake puzzle - Closed - Thomas Klemm - 05-21-2015 01:14 PM (05-21-2015 12:29 PM)Tugdual Wrote:  Thanks but no glory, Haskell is quite amazing for that sort of brute force... Now I guess the real fun to stick on the forum topic would be to find a clever solution to do that with a simple calculator. Or maybe somebody brings Haskell to the HP 50g? Cheers Thomas RE: Vietnamese snake puzzle - Closed - fhub - 05-21-2015 01:18 PM (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. 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