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

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

$
0
0

Haskell, 71 64 51 bytes

g#l=[[x|x<-[1..],c<-w,x==sum[1|e<-g,e==c]]!!0|w<-l]

Try it online!

Full list comprehension solution

  • saved 13 Bytes thanks to @Unrelated String

Old 71 bytes

g#w=sum.f<$>((\y->[1|l<-g,l==y])<$>)<$>wf(h:t)|h<f t=h|1>0=f tf[]=[2]

Try it online!

g#w takes g grid as a string with newlines and w words as a list of words.

Each word is transformed into a list of lists of 1's by g before using f to select the shortest(lexicographically) character.

f has an edge case = [2] for the end of the list which is always greater.
Then sum each selection to obtain the output


Viewing all articles
Browse latest Browse all 20

Trending Articles