Created
July 27, 2010 13:19
-
-
Save hoffmanc/492208 to your computer and use it in GitHub Desktop.
This file contains 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
primes = (1..10000).to_a.delete_if {|n| ('1' * n) =~ /^1?$|^(11+?)\1+$/} | |
bases = Hash.new | |
(2..20).each do |i| | |
ary = [] | |
primes.each do |j| | |
str = j.to_s(i) | |
mid = str.length / 2 | |
p1 = str[0..mid-1] | |
mid = str.length % 2 > 0 ? mid + 1 : mid | |
p2 = str[mid..-1] | |
ary.push(j) if(p1 == p2.reverse) | |
end | |
bases[i] = ary | |
end | |
bases.sort {|a,b| b[1].length <=> a[1].length} .each do |k,v| | |
puts "#{k}: #{v.length}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment