I have the next issue when am trying to use recursion.
Test Cases
puts exact_sum?(12, [1, 2, 3, 4, 5]) => true (he finds it true but returns false)
puts exact_sum?(11, [1, 5, 9, 13]) => false
The behavior of the function is what I am aiming to do but even if he finds true he always returns false.
def exact_sum?(k, coins, i = 0)
if (k == 0) then
print "there is one true #{k}"
return true
elsif (i == coins.length)
return false
end
number = coins[i]
exact_sum?(k-number,coins, i + 1)
exact_sum?(k,coins, i + 1)
end