squarePuzzle.frink

View or download squarePuzzle.frink in plain text format


// Attempt to solve a graphical puzzle,
//  https://mathybeagle.com/2014/09/18/nrich-for-what-its-worth/

use systemSolver2.frink
symbolicMode[true]

simult = new System[[tri + sqr + sqr + tri === 28,
                     hex + sqr + hex + sqr === 30,
                     cir + tri + cir + cir === 18,
                     cir + sqr + cir + cir === 20,
                     sqr + sqr + tri + sqr === 30,
                     sqr + hex + cir + cir === 23,
                     tri + sqr + cir + cir === 22,
                     solution === tri + hex + cir + cir]]
simult.draw[]
println[join["\n",simult.solveAll[]]]

// I was trying this complicated solution until I realized the simpler
// solution === ... line above
/*
tri = simult.solveForValues["tri",[]]@0
hex = simult.solveForValues["hex",[]]@0
cir = simult.solveForValues["cir",[]]@0
println["Solution: " + (tri + hex + cir + cir)]
println[]
*/


View or download squarePuzzle.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 17775 days, 11 hours, 19 minutes ago.