jigglyNumberPuzzle.frink

View or download jigglyNumberPuzzle.frink in plain text format


// This is a simple iterative solution to a puzzle.  It illustrates Frink's
// "multifor" loop and permutation algorithms, and bailing out of loops with
// labeled targets.
//
// Puzzle definition:
// https://twitter.com/snegopa/status/980067722628337665

count = 0
x = new range[1, 9]

NUMS:
multifor nums = [x, x, x, x]
{
   for order = nums.lexicographicPermute[]
   {
      n = parseInt[join["", order]]
      if n mod 12 != 0
         next NUMS
   }

   count = count + 1
   println[join["", nums]]
}

println["Solution is $count"]


View or download jigglyNumberPuzzle.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 17897 days, 19 hours, 44 minutes ago.