Catsylvanian money is a strange thing: they have a coin for every denomination (including zero!). A wonky change machine in Catsylvania takes any coin of value N and returns 3 new coins, valued at N/2, N/3 and N/4 (rounding down).

Write a method `wonky_coins(n)` that returns the number of coins you are left with if you take all non-zero coins and keep feeding them back into the machine until you are left with only zero-value coins.

**Test Cases:**

puts wonky_coins(1).should == 3

puts wonky_coins(5).should == 11

# => [2, 1, 1]

# => [[1, 0, 0], [0, 0, 0], [0, 0, 0]]

# => [[[0, 0, 0], 0, 0], [0, 0, 0], [0, 0, 0]]

puts wonky_coins(6).should == 15

puts wonky_coins(0).should == 1

**My solution (w/ arrays and recursion): **

**Jimmy’s solution (w/o recursion): **

The idea is you draw a coin from a pouch (array). If the coin is 0, count it. If it’s not, redraw another coin until the pouch is empty.

**Provided solution (w/ recursion):**

### Like this:

Like Loading...

*Related*