Created
January 23, 2014 07:51
-
-
Save oropon/8574615 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
# Const | |
CODE_NUMS = 100 | |
CODE_LENGTH = 8 | |
AVAILABLE_CHARS = ('A'..'Z').to_a.delete_if{|c| c == 'O'} | |
AVAILABLE_CHARS_NUM = AVAILABLE_CHARS.length | |
# Throw random nums to suck | |
code_suck = [] | |
(CODE_NUMS*2).times do | |
buff = [] | |
(CODE_LENGTH-1).times {buff << rand(AVAILABLE_CHARS_NUM)} | |
code_suck << buff | |
end | |
# Jangle, jangle | |
code_suck = code_suck | |
.map {|c| c << (c.inject(&:^) % AVAILABLE_CHARS_NUM) } | |
.map {|c| c.map{|n| AVAILABLE_CHARS[n] }.join } | |
.uniq | |
.shuffle | |
.take(CODE_NUMS) | |
puts code_suck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment