Post AFXDDPl1MxdSTZcz8y by servant_of_the_anime_avatars@kiwifarms.cc
 (DIR) More posts by servant_of_the_anime_avatars@kiwifarms.cc
 (DIR) Post #AFX6S0i64pljSTGyxs by sukapon@kiwifarms.cc
       2022-01-17T13:41:09.650951Z
       
       2 likes, 1 repeats
       
       ok so something actually interesting showed up on the firefox start page:https://getpocket.com/explore/item/for-some-maniacal-reason-teachers-gave-this-math-problem-to-9-year-olds?I haven’t read past the problem itself, and obviously this wouldn’t be a viable solution on pen-and-paper lol, but I was kinda hyped to see it instantly produce the answer nonetheless so I’m posting it:foo = head $ do  a <- [0..9]  b <- [0..9]  c <- [0..9]  d <- [0..9]  e <- [0..9]  guard (allDifferent (a,b,c,d,e))  guard ((a*10000+b*1000+c*100+d*10+e) * a     ==  (e*100000+e*10000+e*1000+e*100+e*10+e))  return (a,b,c,d,e)this would probably be even easier in a relational language (miniKanren, Prolog) but nondeterminism-via-list-monad is elegant too.(P.S. yes if there was no solution head would explode, but I was assuming this wasn’t a trick question and that there was at least one solution)
       
 (DIR) Post #AFXDDPl1MxdSTZcz8y by servant_of_the_anime_avatars@kiwifarms.cc
       2022-01-17T14:57:50.861761Z
       
       0 likes, 0 repeats
       
       @sukapon Very cool. What you can do is just look at the furthest left part of the equations.E.g. for A = 2 you would have 04 for the first digits of the result, from this you know that the only possible value for E is 1 (if you carry over 7) and get 11.You can continue that for all all 10 values of A and get 8 pairs (0 and 1 you can exclude immediately).If you then look at the other side of the equation you can immediately exclude all but two of those pairs and of them another one can be excluded by substituting 9 for the remaining variables (even then the result of the multiplication is less than the desired result).And this would have been fairly fast IF I HADN'T CALCULATED SEVEN TIMES SEVEN TO BE 42 AND EXCLUDED THAT POSSIBILITY RIGHT AT THE START. Retardation really hitting hard.