You are viewing a single comment's thread. Return to all comments →
def equal(arr) sum = 1_000_000_000 min = arr.min [0, 1, 2].each do |target| cur_sum = 0 arr.each do |num| diff = num + target - min cur_sum += diff / 5 + diff % 5 / 2 + diff % 5 % 2 / 1 end sum = cur_sum if cur_sum < sum end puts sum end
Seems like cookies are disabled on this browser, please enable them to open this website
Equal
You are viewing a single comment's thread. Return to all comments →
here is mine solution on ruby