Skip to content

Instantly share code, notes, and snippets.

@gar
Created October 6, 2010 17:18
Show Gist options
  • Save gar/613714 to your computer and use it in GitHub Desktop.
Save gar/613714 to your computer and use it in GitHub Desktop.
Which antelope would score the most in Scrabble?
ANTELOPES = [:addax,:antelope,:antilopine,:ariel,:blackbuck,:blaubok,:bluebuck,:bloubok,:blesbok,:blesbuck,:bok,:bongo,:bontebok,:boschbok,:boshbok,:bosbok,:bubal,:bubale,:bubalis,:bubaline,:cabrie,:cabrit,:chamois,:chikara,:chinkara,:chiru,:dikdik,:duiker,:duyker,:duikerbok,:dzeren,:eland,:gazelle,:gemsbok,:gemsbuck,:gerenuk,:gnu,:goa,:gooral,:goral,:grysbok,:hartbees,:hartebeest,:hartbeest,:impala,:inyala,:nyala,:kaama,:klipspringer,:kob,:kongoni,:koodoo,:kudu,:lechwe,:madoqua,:marshbuck,:mhorr,:mohr,:nagor,:nilgai,:nilgau,:nilghai,:nilghau,:nylghai,:nylghau,:oribi,:ourebi,:oryx,:palebuck,:pallah,:prongbuck,:pronghorn,:puku,:pygarg,:reebok,:rhebok,:reedbuck,:reitbok,:saiga,:sasin,:sassaby,:tsessebe,:serow,:shamois,:sitatunga,:situtunga,:springbok,:springbuck,:steenbok,:steinbok,:steinbock,:stembok,:stembuck,:steenbuck,:thar,:topi,:tragelaph,:antelope,:antilopine,:ariel,:blackbuck,:blaubok,:bluebuck,:bloubok,:blesbok,:blesbuck,:bok,:bongo,:bontebok,:boschbok,:boshbok,:bosbok,:bubal,:bubale,:bubalis,:bubaline,:cabrie,:cabrit,:chamois,:chikara,:chinkara,:chiru,:dikdik,:duiker,:duyker,:duikerbok,:dzeren,:eland,:gazelle,:gemsbok,:gemsbuck,:gerenuk,:gnu,:goa,:gooral,:goral,:grysbok,:hartbees,:hartebeest,:hartbeest,:impala,:inyala,:nyala,:kaama,:klipspringer,:kob,:kongoni,:koodoo,:kudu,:lechwe,:madoqua,:marshbuck,:mhorr,:mohr,:nagor,:nilgai,:nilgau,:nilghai,:nilghau,:nylghai,:nylghau,:oribi,:ourebi,:oryx,:palebuck,:pallah,:prongbuck,:pronghorn,:puku,:pygarg,:reebok,:rhebok,:reedbuck,:reitbok,:saiga,:sasin,:sassaby,:tsessebe,:serow,:shamois,:sitatunga,:situtunga,:springbok,:springbuck,:steenbok,:steinbok,:steinbock,:stembok,:stembuck,:steenbuck,:thar,:topi,:tragelaph,:waterbuck]
SCORES = {:a => 1,
:e => 1,
:o => 1,
:n => 1,
:r => 1,
:t => 1,
:l => 1,
:s => 1,
:u => 1,
:i => 1,
:d => 2,
:g => 2,
:b => 3,
:c => 3,
:m => 3,
:p => 3,
:f => 4,
:h => 4,
:v => 4,
:w => 4,
:y => 4,
:k => 5,
:j => 8,
:x => 8,
:q => 10,
:z => 10
}
results = Hash.new
ANTELOPES.each do |antelope|
total = 0
antelope.to_s.each_char {|c| total += SCORES[c.to_sym]}
results[antelope] = total
end
results.sort {|a,b| a.last <=> b.last}.each do |k,v|
puts "%3d %s" % [v,k]
end
4 gnu
4 goa
5 ariel
5 sasin
6 saiga
6 nagor
6 topi
6 goral
6 eland
7 thar
7 nilgai
7 gooral
7 oribi
7 nilgau
8 nyala
8 ourebi
8 serow
8 bongo
9 bubal
9 kudu
9 mohr
9 inyala
9 bok
9 kob
10 sitatunga
10 antelope
10 situtunga
10 cabrit
10 cabrie
10 bubale
10 impala
10 chiru
10 tsessebe
10 puku
10 mhorr
11 kaama
11 duiker
11 nilghai
11 pallah
11 nilghau
11 koodoo
11 bubalis
12 reebok
12 antilopine
12 sassaby
12 gerenuk
12 bubaline
12 kongoni
12 shamois
13 pygarg
13 reitbok
13 hartbees
14 addax
14 steinbok
14 oryx
14 nylghai
14 hartbeest
14 lechwe
14 chamois
14 bosbok
14 duyker
14 steenbok
14 nylghau
15 bloubok
15 stembok
15 rhebok
15 pronghorn
15 tragelaph
15 blesbok
15 blaubok
15 hartebeest
16 chikara
16 dikdik
16 bontebok
16 gemsbok
16 dzeren
17 chinkara
17 steenbuck
17 reedbuck
17 gazelle
17 grysbok
17 steinbock
18 palebuck
18 bluebuck
18 blesbuck
18 springbok
18 boshbok
18 stembuck
19 madoqua
19 gemsbuck
20 prongbuck
20 waterbuck
20 duikerbok
21 klipspringer
21 boschbok
21 springbuck
22 marshbuck ====> WINNER!
25 blackbuck ====> requires a blank for the second k, so would only score 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment