Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created September 5, 2014 08:54
Show Gist options
  • Save rummelonp/44bf0b8482e1e5a86bd6 to your computer and use it in GitHub Desktop.
Save rummelonp/44bf0b8482e1e5a86bd6 to your computer and use it in GitHub Desktop.
ID の強さ
def tuyosa(id)
score = 50
score -= (id.size - 1)
id.chars.each do |char|
score -= 1 if char =~ /_/
score -= 1 if char =~ /[A-Z]/
score -= 2 if char =~ /[0-9]/
end
score * 2
end
ARGV.each do |id|
puts "#{id}: #{tuyosa(id)}"
end
@rummelonp
Copy link
Author

$ ruby id_no_tuyosa.rb t mitukiii
t: 100
mitukiii: 86

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