Last active
March 31, 2017 09:02
-
-
Save kkotaro0111/0531d837cc8a5701749f80f5c84bed93 to your computer and use it in GitHub Desktop.
月壱関東脱出計画の行き先決めるルーレット
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
# use data from MIC | |
# http://www.soumu.go.jp/denshijiti/code.html | |
# | |
# CSV data format | |
# > prefecture, city | |
# Related: 月壱関東脱出計画 | |
# https://peraichi.com/landing_pages/view/escapefromkanto | |
# 仕様 | |
# 47都道府県から1つ、ランダムで選択し、次に、その都道府県に属する市区町村をランダムで1つ選択する | |
# Modify | |
# 2017.03.30 by tarom | |
require 'csv' | |
prefectures = {} | |
CSV.foreach('cities.csv', headers: true) do |row| | |
next if row['city'].nil? | |
prefecture = row['prefecture'] | |
prefectures[prefecture] ||= [] | |
prefectures[prefecture] << row['city'] | |
end | |
puts 'prefecture roulette...' | |
prefecture = prefectures.keys.sample | |
puts prefecture | |
puts 'city roulette...' | |
city = prefectures[prefecture].sample | |
puts city |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment