Skip to content

Instantly share code, notes, and snippets.

@nawada
Created February 9, 2022 11:22
Show Gist options
  • Save nawada/7c3e454af86766fae6c2842087ca8cee to your computer and use it in GitHub Desktop.
Save nawada/7c3e454af86766fae6c2842087ca8cee to your computer and use it in GitHub Desktop.
Wordle用補助ツール
in_file_path = '/usr/share/dict/web2'
files = []
Dir.glob(in_file_path) do |file|
files.push(file)
end
five_char_words = []
File.open(in_file_path) do |file|
file.each_line do |line|
line.strip!
if line.length === 5 && line.match?(/[a-zA-Z]{5}/)
five_char_words.push(line)
end
end
end
out_file_path = './five_words.txt'
File.open(out_file_path, 'w', 0755) do |file|
five_char_words.each do |word|
file.puts(word)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment