4-rings or 4-squares puzzle: Difference between revisions

→‎{{header|11l}}: Shortened version
(Added 11l)
(→‎{{header|11l}}: Shortened version)
Line 48:
 
<lang 11l>F foursquares(lo, hi, unique, show)
 
F acd_arr()
Iterates through all the possible valid values of
a, c, and d.
 
a = c + d
[(Int, Int, Int)] r
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)
r [+]= (a, c, d)
R r
 
V solutions = 0
L(acdc) acd_arr()lo .. hi
V L(a, c, d) =lo .. acdhi
a =I !unique | (c +!= d)
 
F ge_arr() V a = c + d
I a >= lo & a <= hi
Iterates through all theI possible!unique valid| values(c of!= 0 & d != 0)
g and L(e) lo .. hi
I (!@unique) | (ce !=C (a, c, d))
 
V g = d + e
I g >= lo & g <= hi
[ I !unique | (Intg !C (a, Int)]c, rd, e))
L(ef) @lo .. @hi
I (!@unique) | (ef !C (@a, @c, @d, g, e))
V gb = @de + ef - c
I gb >= @lo & gb <= @hi
I (!@unique) | (gb !C (@a, @c, @d, g, e, f))
r [+]= (g, e) solutions++
R r I show
print(String((a, b, c, d, e, f, g))[1 .< (len)-1])
 
L(ge) ge_arr()
V (g, e) = ge
 
F bf_arr()
Iterates through all the possible valid values of
b and f.
 
b = e + f - c
[(Int, Int)] r
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))
r [+]= (b, f)
R r
 
L(bf) bf_arr()
V (b, f) = bf
solutions++
I show
print(String((a, b, c, d, e, f, g))[1 .< (len)-1])
 
V uorn = I unique {‘unique’} E ‘non-unique’
 
print(String(solutions)‘solutions‘ ’uorn‘ solutions in ’String(lo)‘’lo‘ to ’String(hi)’hi)
print()
 
1,481

edits