Live data from Hacker News

A (deceptively tricky?) Python question

news.ycombinator.com

11–12 of 12 posts

Re: A (deceptively tricky?) Python question

#11
post #3

Try this for when you need to fill 2 blank tiles: import string from itertools import product w = "H_LL_" w_fmt = w.replace('_', '%s') product_args = [list(string.uppercase)] * 2 expanded = [w_fmt % repl for repl in product(*product_args)]

Many thanks! I'm using it now.

Re: A (deceptively tricky?) Python question

#12
Do you want to just find dictionary words based on board configuration and a bench? Typically they build a Directed Acyclic Word Graph from the dictionary and then you can just traverse the graph.

So for your example, you start at the H node and follow all paths. Then follow the L path if it exists. Then follow the next L path. Then follow all paths from that node. Then check if the word has ended.

Post reply on HN