jonadsimon / wonder-words-generator

Generates WonderWords puzzles
Apache License 2.0
2 stars 0 forks source link

Impute Random Letters if no Fallback found #76

Closed jonadsimon closed 2 years ago

jonadsimon commented 2 years ago

Wrote disconnect post-processing script to insert random letters into the board with the same frequencies as the letters already within the board. Add this logic to the main loop, with a warning.

import random

def impute_letters(s):
     rows = [row.strip().split() for row in s.strip().split("\n")]
     letters = [c for row in rows for c in row if c != "_"]
     for c in s:
         if c == "_":
             print(random.sample(letters, 1)[0], end="")
         else:
             print(c, end="")
jonadsimon commented 2 years ago

Fixed in https://github.com/jonadsimon/wonder-words-generator/commit/02d2fb8ade74d592d352a03ae29b9b86e13d0ee5