loading...

Discussion on: Daily Challenge #132 - Is my friend cheating?

Collapse
citizen428 profile image
Michael Kohl

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]]