Quantcast
Channel: Words with Easy Letters in a Word Search - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 20

Answer by Neil for Words with Easy Letters in a Word Search

$
0
0

Retina 0.8.2, 74 bytes

\G(.+)¶$1ms`(?<=^(.+)¶.+)$;$11A`%(`\G(.)(?=(.*?\1)+)$#2¶A`;O#`1G`

Try it online! Explanation:

\G(.+)¶$1

Flatten the grid.

ms`(?<=^(.+)¶.+)$;$1

Append a copy of the grid to each word in the list.

1A`

Delete the original grid.

%(`

Repeat for each pair of word and flattened grid.

\G(.)(?=(.*?\1)+)$#2¶

Count the number of times each letter in the word appears in the grid. (Note that when a letter in the word is repeated then the count is only correct for the last letter but this doesn't affect the final result.)

A`;

Delete the grid.

O#`

Sort the counts.

1G`

Keep only the first (i.e. smallest).


Viewing all articles
Browse latest Browse all 20

Trending Articles