How to resolve the algorithm 4-rings or 4-squares puzzle step by step in the 11l programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm 4-rings or 4-squares puzzle step by step in the 11l programming language

Table of Contents

Problem Statement

Replace       a, b, c, d, e, f,   and   g       with the decimal digits   LOW   ───►   HIGH such that the sum of the letters inside of each of the four large squares add up to the same sum. Show all output here.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm 4-rings or 4-squares puzzle step by step in the 11l programming language

Source code in the 11l programming language

F foursquares(lo, hi, unique, show)
   V solutions = 0
   L(c) lo .. hi
      L(d) lo .. hi
         I !unique | (c != d)
            V a = c + d
            I a >= lo & a <= hi
               I !unique | (c != 0 & d != 0)
                  L(e) lo .. hi
                     I !unique | (e !C (a, c, d))
                        V g = d + e
                        I g >= lo & g <= hi
                           I !unique | (g !C (a, c, d, e))
                              L(f) lo .. hi
                                 I !unique | (f !C (a, c, d, g, e))
                                    V b = e + f - c
                                    I b >= lo & b <= hi
                                       I !unique | (b !C (a, c, d, g, e, f))
                                          solutions++
                                          I show
                                             print(String((a, b, c, d, e, f, g))[1 .< (len)-1])

   V uorn = I unique {‘unique’} E ‘non-unique’

   print(solutions‘ ’uorn‘ solutions in ’lo‘ to ’hi)
   print()

foursquares(1, 7, 1B, 1B)
foursquares(3, 9, 1B, 1B)
foursquares(0, 9, 0B, 0B)

  

You may also check:How to resolve the algorithm Ternary logic step by step in the RPL programming language
You may also check:How to resolve the algorithm Numerical integration step by step in the OCaml programming language
You may also check:How to resolve the algorithm Stair-climbing puzzle step by step in the Factor programming language
You may also check:How to resolve the algorithm Random number generator (included) step by step in the V (Vlang) programming language
You may also check:How to resolve the algorithm Return multiple values step by step in the Delphi/Pascal programming language