Skip to content

Instantly share code, notes, and snippets.

@lukebergen
Created June 17, 2015 01:09
Show Gist options
  • Save lukebergen/1ec41452433087eb4def to your computer and use it in GitHub Desktop.
Save lukebergen/1ec41452433087eb4def to your computer and use it in GitHub Desktop.
def paths(n, path=[], result=[])
if n == 0
result << path
elsif n > 0
[2, 3, 7].each {|score| paths(n - score, path + [score], result)}
end
result
end
puts paths(1).to_s
puts paths(14).to_s
puts paths(5).to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment