#
# Puzzle

# https://medium.com/math-simplified/can-you-really-solve-this-third-grade-math-puzzle-b6c1b7637971
# """ 
# Can you really Solve this Third-Grade Math Puzzle?
#  1  5
#  2 10
#  3 55
# 10  ?
# """
#
# One thought:
# 1 -> 5 just given
# 10 -> 2*1 * 5 - 0
# 55 -> 3*2 * 10 - 5
# ?  -> 10*3 * 55 - 10 = 1640 ??
#
# Solutions:
# 
# (V3 + (V3 + ((V3 + (V3 + (V3 + (V3 * (V1 * V2))))) - V2))) - V2 
# -> -2 V2 + 5 V3 + V1 V2 V3
# Testing the fittest program with user defined test data: 
# 3.0 55.0 10.0    Result: 1590.0
# 
# 
presentation: Puzzle
# num_input_variables: 1
# variable_names: a x
# functions: Multiply,Divide,Add,Subtract
functions: Multiply,Add,Subtract
# functions: Add,Multiply
# functions: ForLoopD
# functions: Multiply,Add,Subtract,Divide
terminal_range: 0 100
max_init_depth: 4
population_size: 1000
max_crossover_depth: 8
num_evolutions: 1000
max_nodes: 21
mutation_prob: 0.15
crossover_prob: 0.9
stop_criteria_fitness: 0
show_similiar: true
show_results: true
# show_population: true
data

# 1  5
# 2 10
# 3 55
# 10 ?

# Here's one solution:
# ((((((((V1 * V2) - V2) * V1) * V1) + V3) + V3) + V3) + V3) + V3 
# 3.0 55.0 10.0    Result: 1040.0
# Simplifies to 
#           2
# Out[1]= V1  (-V2 + V1 V2) + 5 V3
#
# Another solution
# (V3 + ((V3 + ((V3 + (((V2 * V3) * V1) + V3)) - V2)) + V3)) - V2
# 3.0 55.0 10.0    Result: 1590.0
# Simplifies to
# Out[1]= -2 V2 + 5 V3 + V1 V2 V3
#
# Third solution:
# (3.0 + (V3 + (V3 + (V1 * (V1 * (V1 * (V3 + V3))))))) - V1 [1]
# 3.0 55.0 10.0    Result: 560.0
# Simplifies to
#                              3
# Out[1]= 3. - V1 + 2 V3 + 2 V1  V3
#
# OK, let's test it once more...

0  0  1  5
1  5  2 10
2 10  3 55
3 55 10 ?


#
# Here is one solution:
# 
# ((V7 + (V7 + V7)) + (((V4 * V6) + V7) - (V4 * V5))) + V7
# 1.0 5.0 2.0 10.0 3.0 55.0 10.0    Result: 570.0
# simplifies to 
#   Out[1]= -(V4 V5) + V4 V6 + 5 V7
#
# Another solution:
# V7 + (V7 + ((V7 - V2) + ((((V7 + (V7 + V5)) * V4) + V7) + V7)))
# 1.0 5.0 2.0 10.0 3.0 55.0 10.0    Result: 275.0
# Simplifies to 
# -V2 + 5 V7 + V4 (V5 + 2 V7)
#
# Third solution
# V7 + (V7 + (V7 + (V7 + (V7 + (40.0 * V3)))))
# 1.0 5.0 2.0 10.0 3.0 55.0 10.0    Result: 130.0
# Simplifies to 
# 40. V3 + 5 V7
#
## 1 2 3  4  5  6  7  8
 # 0 0 0  0  0  0  1  5
 # 0 0 0  0  1  5  2 10
 # 0 0 1  5  2 10  3 55
 # 1 5 2 10  3 55 10 ?
