Skip to content

Instantly share code, notes, and snippets.

@lukerandall
Created February 19, 2009 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukerandall/66934 to your computer and use it in GitHub Desktop.
Save lukerandall/66934 to your computer and use it in GitHub Desktop.
DVORAK = {
:a => 0,
:b => 4,
:c => 2,
:d => 1,
:e => 0,
:f => 2,
:g => 2,
:h => 0,
:i => 1,
:j => 4,
:k => 4,
:l => 2,
:m => 4,
:n => 0,
:o => 0,
:p => 2,
:q => 4,
:r => 2,
:s => 0,
:t => 0,
:u => 0,
:v => 4,
:w => 4,
:x => 4,
:y => 2,
:z => 4,
}
QWERTY = {
:a => 0,
:b => 4,
:c => 4,
:d => 0,
:e => 2,
:f => 0,
:g => 1,
:h => 1,
:i => 2,
:j => 0,
:k => 0,
:l => 0,
:m => 4,
:n => 4,
:o => 2,
:p => 2,
:q => 2,
:r => 2,
:s => 0,
:t => 2,
:u => 2,
:v => 4,
:w => 2,
:x => 4,
:y => 2,
:z => 4,
}
WORDS = [
"the",
"be",
"to",
"of",
"and",
"a",
"in",
"that",
"have",
"I",
"Word",
"it",
"for",
"not",
"on",
"with",
"he",
"as",
"you",
"do",
"at",
"this",
"but",
"his",
"by",
"from",
"they",
"we",
"say",
"her",
"she",
"or",
"an",
"will",
"my",
"one",
"all",
"would",
"there",
"their",
"what",
"so",
"up",
"out",
"if",
"about",
"who",
"get",
"which",
"go",
"me",
"when",
"make",
"can",
"like",
"time",
"no",
"just",
"him",
"know",
"take",
"people",
"into",
"year",
"your",
"good",
"some",
"could",
"them",
"see",
"other",
"than",
"then",
"now",
"look",
"only",
"come",
"its",
"over",
"think",
"also",
"back",
"after",
"use",
"two",
"how",
"our",
"work",
"first",
"well",
"way",
"Word",
"even",
"new",
"want",
"because",
"any",
"these",
"give",
"day",
"most",
"us"
]
dvorak_total = 0
qwerty_total = 0
puts "WORD DVORAK QWERTY RESULT"
puts "------------------------------------------"
WORDS.each do |word|
dvorak = 0
qwerty = 0
result = ''
0.upto(word.size - 1) do |n|
k = word[n,1].downcase.to_sym
dvorak += DVORAK[k]
qwerty += QWERTY[k]
end
if dvorak < qwerty
result = '-'
elsif dvorak > qwerty
result = '+'
end
puts "#{word.ljust(10)} #{dvorak.to_s.center(8)} #{qwerty.to_s.center(13)} #{result.center(10)}"
dvorak_total += dvorak
qwerty_total += qwerty
end
puts "------------------------------------------"
puts "#{'TOTAL'.ljust(10)} #{dvorak_total.to_s.center(10)} #{qwerty_total.to_s.center(10)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment