Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 193 characters in body
Source Link
AZTECCO
  • 11k
  • 1
  • 17
  • 60

Haskell, (削除) 71 64 (削除ここまで) 6451 bytes

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

Try it online! 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])<$>)<$>w
f(h:t)|h<f t=h|1>0=f t
f[]=[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

Haskell, (削除) 71 (削除ここまで) 64 bytes

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

Try it online!

Full list comprehension solution

Old 71 bytes

g#w=sum.f<$>((\y->[1|l<-g,l==y])<$>)<$>w
f(h:t)|h<f t=h|1>0=f t
f[]=[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

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])<$>)<$>w
f(h:t)|h<f t=h|1>0=f t
f[]=[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

added 1002 characters in body
Source Link
AZTECCO
  • 11k
  • 1
  • 17
  • 60

Haskell, 71(削除) 71 (削除ここまで) 64 bytes

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

Try it online!

Full list comprehension solution

Old 71 bytes

g#w=sum.f<$>((\y->[1|l<-g,l==y])<$>)<$>w
f(h:t)|h<f t=h|1>0=f t
f[]=[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

Haskell, 71 bytes

g#w=sum.f<$>((\y->[1|l<-g,l==y])<$>)<$>w
f(h:t)|h<f t=h|1>0=f t
f[]=[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

Haskell, (削除) 71 (削除ここまで) 64 bytes

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

Try it online!

Full list comprehension solution

Old 71 bytes

g#w=sum.f<$>((\y->[1|l<-g,l==y])<$>)<$>w
f(h:t)|h<f t=h|1>0=f t
f[]=[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

Source Link
AZTECCO
  • 11k
  • 1
  • 17
  • 60

Haskell, 71 bytes

g#w=sum.f<$>((\y->[1|l<-g,l==y])<$>)<$>w
f(h:t)|h<f t=h|1>0=f t
f[]=[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

AltStyle によって変換されたページ (->オリジナル) /