Created
March 27, 2012 13:52
-
-
Save caingougou/2216076 to your computer and use it in GitHub Desktop.
vampire numbers
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
| #!/usr/bin/env ruby | |
| require 'pp' | |
| nums = (1...100).to_a | |
| nums.each do |n| | |
| nums.each do |m| | |
| (n.to_s + m.to_s).split('').permutation().to_a.each do |p| | |
| if ( p.join('') == (n*m).to_s ) | |
| print p.join('') + "=" + n.to_s + "*" + m.to_s + "\n" | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment