Created
September 24, 2012 21:17
-
-
Save Frost/3778431 to your computer and use it in GitHub Desktop.
Nippes bigram
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
#!/usr/bin/env ruby | |
letters = "A".."Z" | |
numbers = 0..9 | |
bigrams = letters.map do |letter| | |
numbers.map do |number| | |
letter + number.to_s | |
end | |
end | |
bigrams = bigrams.flatten.sort_by { rand } | |
with_numbers = [] | |
bigrams.each_with_index do |bigram, index| | |
with_numbers << [bigram, "%0.3d" % ( index + 1 )] | |
end | |
ordered_by_letter = with_numbers.sort_by(&:first) | |
ordered_by_number = with_numbers.map(&:reverse).sort | |
puts ordered_by_letter.map {|i| i.join(' = ')} | |
puts | |
puts ordered_by_number.map {|i| i.join(' = ')} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment