Skip to main content
added 1 character in body
Source Link
user39732
user39732

Top 10 contenders:

enter image description here

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 4494444,944.

Top 10 contenders:

enter image description here

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 44944.

Top 10 contenders:

enter image description here

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.

deleted 5 characters in body
Source Link
user39732
user39732

Top 10 contenders:

enter image description here

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.uniq.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 44944.

Top 10 contenders:

enter image description here

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.uniq.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 44944.

Top 10 contenders:

enter image description here

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 44944.

added 3 characters in body
Source Link
user39732
user39732

Top 10 contenders:

enter image description here

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.uniq.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 44944.

Top contenders:

enter image description here

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.uniq.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 44944.

Top 10 contenders:

enter image description here

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.uniq.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 44944.

added 355 characters in body
Source Link
user39732
user39732
Loading
added 8 characters in body
Source Link
user39732
user39732
Loading
Source Link
user39732
user39732
Loading