How to resolve the algorithm Anagrams/Deranged anagrams step by step in the PicoLisp programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Anagrams/Deranged anagrams step by step in the PicoLisp programming language
Table of Contents
Problem Statement
Two or more words are said to be anagrams if they have the same characters, but in a different order. By analogy with derangements we define a deranged anagram as two words with the same characters, but in which the same character does not appear in the same position in both words. Use the word list at unixdict to find and display the longest deranged anagram.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Anagrams/Deranged anagrams step by step in the PicoLisp programming language
Source code in the picolisp programming language
(let Words NIL
(in "unixdict.txt"
(while (line)
(let (Word @ Key (pack (sort (copy @))))
(if (idx 'Words Key T)
(push (car @) Word)
(set Key (list Word)) ) ) ) )
(maxi '((X) (length (car X)))
(extract
'((Key)
(pick
'((Lst)
(and
(find
'((L) (not (find = L Lst)))
(val Key) )
(cons (pack @) (pack Lst)) ) )
(val Key) ) )
(idx 'Words) ) ) )
You may also check:How to resolve the algorithm Create a file step by step in the Lang programming language
You may also check:How to resolve the algorithm URL parser step by step in the C# programming language
You may also check:How to resolve the algorithm Compile-time calculation step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm 24 game step by step in the Scala programming language
You may also check:How to resolve the algorithm Conditional structures step by step in the Crack programming language