loading...

re: Daily Challenge #132 - Is my friend cheating? VIEW POST

FULL DISCUSSION
 

Ruby:

def remove_numbers(n)
  (1..n).to_a.repeated_permutation(2).select do |a, b| 
    a * b == n * (n + 1) / 2 - a - b
  end
end

remove_numbers(26)
#=> [[15, 21], [21, 15]]
Code of Conduct Report abuse