|
|
Line 1: |
Line 1: |
|
{{task|Text processing}} |
|
{{task|Text processing}} |
|
Two or more words can be composed of the same characters, but in a different order. Using the word list at http://www.puzzlers.org/pub/wordlists/unixdict.txt, find the sets of words that share the same characters that contain the most words in them. |
|
Two or more words can be composed of the same characters, but in a different order. Using the word list at http://www.puzzlers.org/pub/wordlists/unixdict.txt, find the sets of words that share the same characters that contain the most words in them. |
|
|
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
groupon f x y = (f x) == (f y) |
|
|
|
|
⚫ |
|
|
⚫ |
f <- readFile "./../Puzzels/Rosetta/unixdict.txt" |
|
⚫ |
|
|
⚫ |
wix = groupBy (groupon fst) . sort $ zipWith ((,).sort) words words |
|
⚫ |
mxl = foldl' ((.length).max) 0 wix |
|
⚫ |
print . map (map snd) . filter ((==mxl).length) $ wix |
|
|
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
|
|
|
⚫ |
(#~a:~:{:"1)(]/.~/:~&>)<;.2]1!:1<'unixdict.txt' |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|abel |able |bale |bela |elba | |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|alger|glare|lager|large|regal| |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|angel|angle|galen|glean|lange| |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|caret|carte|cater|crate|trace| |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|elan |lane |lean |lena |neal | |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|evil |levi |live |veil |vile | |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
|
|
|
|
=={{header|Java}}== |
|
=={{header|Java}}== |
Line 39: |
Line 72: |
|
[abel, able, bale, bela, elba] |
|
[abel, able, bale, bela, elba] |
|
[evil, levi, live, veil, vile] |
|
[evil, levi, live, veil, vile] |
|
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
groupon f x y = (f x) == (f y) |
|
|
|
|
⚫ |
|
|
⚫ |
f <- readFile "./../Puzzels/Rosetta/unixdict.txt" |
|
⚫ |
|
|
⚫ |
wix = groupBy (groupon fst) . sort $ zipWith ((,).sort) words words |
|
⚫ |
mxl = foldl' ((.length).max) 0 wix |
|
⚫ |
print . map (map snd) . filter ((==mxl).length) $ wix |
|
|
|
|
⚫ |
|
|
|
|
|
⚫ |
|
|
|
|
|
⚫ |
(#~a:~:{:"1)(]/.~/:~&>)<;.2]1!:1<'unixdict.txt' |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|abel |able |bale |bela |elba | |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|alger|glare|lager|large|regal| |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|angel|angle|galen|glean|lange| |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|caret|carte|cater|crate|trace| |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|elan |lane |lean |lena |neal | |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
⚫ |
|evil |levi |live |veil |vile | |
|
⚫ |
+-----+-----+-----+-----+-----+ |
|
|
|
|
|
|
=={{header|Python}}== |
|
=={{header|Python}}== |