KaplinskyPuzzle.frink

Download or view KaplinskyPuzzle.frink in plain text format


/** Solver for a problem:

    https://twitter.com/robertkaplinsky/status/1057037622995009543
*/


a = array[1 to 9]
smallest = 1e100

for c = a.combinations[6]
{
   for p = c.permute[]
   {
      n1 = sqrt[p@0 * 100 + p@1 * 10 + p@2]
      n2 = sqrt[p@3 * 10 + p@4]
      n3 = sqrt[p@5]
      n = n1 - n2 - n3
      
      if abs[n] <= smallest
      {
         println["$p\t$n"]
         smallest = abs[n]
      }
   }
}


Download or view KaplinskyPuzzle.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 19973 days, 11 hours, 11 minutes ago.