Skip to content

Instantly share code, notes, and snippets.

@mklemme
Created December 4, 2014 20:11
Show Gist options
  • Save mklemme/c18a8f8722f743bb43f0 to your computer and use it in GitHub Desktop.
Save mklemme/c18a8f8722f743bb43f0 to your computer and use it in GitHub Desktop.
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
@prschulz
Copy link

prschulz commented Dec 4, 2014

fancy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment