Skip to content

Instantly share code, notes, and snippets.

@Frost
Created September 24, 2012 21:17
Show Gist options
  • Save Frost/3778431 to your computer and use it in GitHub Desktop.
Save Frost/3778431 to your computer and use it in GitHub Desktop.
Nippes bigram
#!/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