ルール:
使ったコードは以下:
#!/usr/bin/env ruby require 'abbrev' prefs = DATA.each_line.map {|l| l.strip.split('-').first.downcase } abbreviates = Abbrev.abbrev(prefs) unique_prefs = abbreviates.keys.select {|k| k.size == 1 }.map {|k| abbreviates[k] } puts unique_prefs __END__ Hokkai-do Aomori-ken Iwate-ken Miyagi-ken Yamagata-ken Fukushima-ken Ibaraki-ken Tochigi-ken Gunma-ken Saitama-ken Chiba-ken Tokyo-to Kanagawa-ken Niigata-ken Toyama-ken Ishikawa-ken Fukui-ken Yamanashi-ken Nagano-ken Gifu-ken Shizuoka-ken Aichi-ken Mie-ken Shiga-ken Kyoto-fu Osaka-fu Hyogo-ken Nara-ken Wakayama-ken Tottori-ken Shimane-ken Okayama-ken Hiroshima-ken Yamaguchi-ken Tokushima-ken Kagawa-ken Ehime-ken Kochi-ken Fukuoka-ken Saga-ken Nagasaki-ken Kumamoto-ken Oita-ken Miyazaki-ken Kagoshima-ken Okinawa-ken
実質5行で求められて便利。abbrevはたまにこういうことするのに便利で好き。
結果は: