Fill the blanks by using each of the four arithmetical operations only once ($+$,$-$,$\div$,$\times$) to make the result biggest:
For example:
$121-2+12\times12\div1=263$ but this is not the biggest result you can get.
Fill the blanks by using each of the four arithmetical operations only once ($+$,$-$,$\div$,$\times$) to make the result biggest:
For example:
$121-2+12\times12\div1=263$ but this is not the biggest result you can get.
my best answer(No longer my best, but I left it as it was my best at one time..)
1+2121x21-2/1=44540
I got to this using the following logic
multiplication is the only function that will grow the answer in a big way, so we need to optimize the multiplication- beginning the largest number with a 2 is in our best interest, so we needed to chop the 1 off the front. can not use a minus here, as it would make our result negative. which leaves only addition. This leaves only - and / remaining. To divide by 2 -1 would divide the answer by 2 then minus 1, so we are left with my answer.
a new answer!
1+212/1x212-1 = 44944
I got this by
using the same logic but playing with the placement of the division. this shortened up my longest integer by 1, but added 100 to the second largest (in this case even) It works out to be a larger number, albeit not by much.
Top 10 contenders:
My approach using Ruby:
num = [1,0,2,0,1,0,2,0,1,0,2,0,1,0,2,0,1]
opr = [3,4,5,6]
#3->+
#4->-
#5->/
#6->*
plc = [1,3,5,7,9,11,13,15]
$i=0
results = []
express = []
while $i < 100000 do
opr = opr.shuffle
tempRand=plc.shuffle.take(4)
num[tempRand[0].to_i] = opr[0]
num[tempRand[1].to_i] = opr[1]
num[tempRand[2].to_i] = opr[2]
num[tempRand[3].to_i] = opr[3]
tempString = ''
num.each do |e|
if e.to_i == 0
tempString << ''
elsif e.to_i == 3
tempString << '+'
elsif e.to_i == 4
tempString << '-'
elsif e.to_i == 5
tempString << '/'
elsif e.to_i == 6
tempString << '*'
else
tempString << e.to_s
end
end
results << eval(tempString)
express << tempString
num[tempRand[0].to_i] = 0
num[tempRand[1].to_i] = 0
num[tempRand[2].to_i] = 0
num[tempRand[3].to_i] = 0
$i += 1
end
print_me = Hash[results.zip(express)]
puts print_me.sort.reverse
(try it here)
Basically just randomly swap the 0s (the blank spaces) with operators and then evaluate the result without 0s. It's not the best way to do it, but over a 100,000 iterations the max is 44,944.
Best I could come up with:
121 x 212 - 1 + 2 ÷ 1 = 25,653
1 + 21212 / 1 * 2 - 1 = 42425