"((7 - 2 - 2)^2 )^2 - 2 = 79"
#Ruby22
def f0(number, log)
return [number * number, "(" + log + ")^2 "]
end
def f1(number, log)
return [number - 2, log + " - 2"]
end
end_num = 79
for n in 1..5
for i in 0..2**n-1
s = ("000000000000000000000000000000" + i.to_s(2))[-n..-1]
start_num = 7
log = start_num.to_s
for k in 0..s.size-1
start_num, log = f0(start_num, log) if s[k] == "0"
start_num, log = f1(start_num, log) if s[k] == "1"
# break if start_num > end_num
end
# p [start_num, log, s, n]
if start_num == end_num then
log += " = " + end_num.to_s
p log
end
end
end