Created
December 4, 2014 20:11
-
-
Save mklemme/c18a8f8722f743bb43f0 to your computer and use it in GitHub Desktop.
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
string = "g7fj10jsofo2invwoqnfvoi34rngua8vhqjefoainwekfuvy3nbf".downcase | |
string_count = 0 | |
alphabet =[ | |
"a", | |
"b", | |
"c", | |
"d", | |
"e", | |
"f", | |
"g", | |
"h", | |
"i", | |
"j", | |
"k", | |
"l", | |
"m", | |
"n", | |
"o", | |
"p", | |
"q", | |
"r", | |
"s", | |
"t", | |
"u", | |
"v", | |
"w", | |
"x", | |
"y", | |
"z" | |
] | |
hash = Hash[alphabet.map.with_index.to_a] | |
string.each_char do |e| | |
if /[a-z]/ =~ e | |
string_count += hash[e] + 1 | |
end | |
end | |
p string_count | |
# check if number is prime | |
require 'prime' | |
if Prime.instance.prime?(string_count) | |
p "Yes" | |
else | |
p "Nope" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fancy