Skip to content

Instantly share code, notes, and snippets.

@caingougou
Created March 27, 2012 13:52
Show Gist options
  • Select an option

  • Save caingougou/2216076 to your computer and use it in GitHub Desktop.

Select an option

Save caingougou/2216076 to your computer and use it in GitHub Desktop.
vampire numbers
#!/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