Skip to content

Conversation

@narze
Copy link
Owner

@narze narze commented Dec 2, 2025

words = File.open("./import.txt").readlines.map(&:strip).uniq

words.map { |word| word.gsub(/[^ก-ฮa-zA-Zใเแโไาำะๆฯฤา]/, "").length }.tally
words_with_length = words.map { |word| [word, word.gsub(/[^ก-ฮa-zA-Zใเแโไาำะๆฯฤา]/, "").length] }

words_4 = words_with_length.select { |word, length| length == 4 }.shuffle # 429 words
words_5_and_above = words_with_length.select { |word, length| length >= 5 }.shuffle # 1479 words

puts "words_4: #{words_4.length}"
puts "words_5_and_above: #{words_5_and_above.length}"
total_length = words_4.length + words_5_and_above.length
puts "total: #{total_length}"

# overlay words_4 every 4 words of 5+ length
words_combined = words_5_and_above.each_slice(4).flat_map do |slice|
  if words_4.any?
    slice.concat(words_4.pop(1))
  else
    slice
  end
end

# If there are some words_4 left, randomly add them to the words_combined at random places
if words_4.any?
  words_4.each do |word|
    index = rand(words_combined.length)
    puts "inserting word #{word} at index #{index}"
    words_combined.insert(index, word)
  end
end

words_to_export = words_combined.map(&:first)

puts "total words to export: #{words_to_export.length}"

raise "Error" if words_to_export.length != total_length

File.open("export.txt", "w+") do |f|
  words_to_export.each { |element| f.puts("\"#{element}\",") }
end

@vercel
Copy link

vercel bot commented Dec 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
thwordle Ready Ready Preview Comment Dec 2, 2025 4:02pm

@narze narze changed the title Add more words with 4 length words Add 2k more words (with 4 length words) Dec 2, 2025
@narze narze merged commit a02c593 into main Dec 2, 2025
7 checks passed
@narze narze deleted the add-words branch December 2, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants