Created
August 18, 2012 23:51
-
-
Save lune-sta/3390398 to your computer and use it in GitHub Desktop.
Project Euler 31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $p = [1,2,5,10,20,50,100,200] | |
| $ans = 0 | |
| def dfs(n) | |
| case n.inject{|a,b|a+b} | |
| when 0..199 | |
| $p.each{|a|dfs(n<<a)} | |
| when 200 | |
| $ans += 1 | |
| p n | |
| else | |
| end | |
| end | |
| $p.each{|a|dfs([a])} | |
| p $ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment