#
#  See
#   - http://www.hakank.org/minizinc/equation.mzn
#   - http://www.hakank.org/bprolog/equation.pl
#   - http://www.hakank.org/picat/equation.pi
# 11x11=4 
# 22x22=16 
# 33x33=?
#
# The constraint models above has 4 different models/interpretations and
# finds four different solutions of the puzzle:
#   x1 = 36
#   x2 = 18
#   x3 = 64
#   x4 = 108
# 
# Later:
# MindYourDecision (Presh Talwalkar) has blogged/youtubed about it:
#  "Viral Puzzle 11 x 11 = 4. The Correct Answer Explained" 
# - https://mindyourdecisions.com/blog/2016/09/21/viral-puzzle-11x11-4-the-correct-answer-explained/
# - https://www.youtube.com/watch?v=IQd1oDsHVSc
#
# The Symbolic Regression program finds a lot of different answers but it seems that it
# always tends towards the solution of 36. E.g.
#  (b + b) * (b + b) [4021]
#  (d + (if(90.0) then (c))) * (b + b) [1555]
#  (d + b) * (b + b) [1449]
#  (b + b) * (d + b) [1394]
#  (b + b) * (b + d) [1269]
#  (b + d) * (b + b) [1173]
#  (b + d) * (b + d) [1098]
#  (b + b) * (c + a) [981]
#
#
presentation: Equation
num_input_variables: 4
variable_names: a b c d x
# functions: Multiply,Add,Subtract,Divide
# functions: Multiply,Divide,Add,Subtract,Sqrt,Pow
# functions: Multiply,Divide,Add,Subtract,Modulo
functions: Multiply,Divide,Add,Subtract,Modulo,GreaterThan,LesserThan,IfElse,If,Equals,And,Or,Not,Xor
terminal_range: -100 100
terminal_wholenumbers: true
max_init_depth: 4
population_size: 1000
max_crossover_depth: 8
num_evolutions: 1000
max_nodes: 21
mutation_prob: 0.25
crossover_prob: 0.9
show_similiar: true
# show_population: true
# show_progression: true
show_results: true
# stop_criteria_fitness: 0
data

1 1 1 1 4 
2 2 2 2 16 
3 3 3 3 ?
