Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def houseOfCats(legs)
- output_array = Array.new
- x = legs
- y = 0
- if legs % 4 == 0 then
- output_array[y] = 0
- y = y + 1
- end
- while (x >= 0)
- if x - 4 > 0 then
- x = x - 4
- else
- break
- end
- end
- output_array[y] = x / 2
- y = y + 1
- x = 1
- while (x * 2 <= legs)
- amount = legs - (2 * x)
- if legs - (2 * x) == 0 or amount % 4 == 0 then
- output_array[y] = x
- y = y + 1
- end
- x = x + 1
- end
- return output_array.uniq
- end
Advertisement
Add Comment
Please, Sign In to add comment