Anadromes: Difference between revisions

no edit summary
m (Remove draft tag. Draft for over a year, multiple implementations, little controvery)
imported>Chinhouse
No edit summary
Line 631:
sallets <=> stellas
sennits <=> stinnes
</pre>
 
=={{header|MiniScript}}==
This implementation is for use with the [http://miniscript.org/MiniMicro Mini Micro] version of MiniScript. The command-line version does not include a HTTP library. Modify the declaration of wordList object to use the file class instead of the http class.
<syntaxhighlight lang="miniscript">getPairs = function(words)
pairs = []
for i in range(0, words.len - 2)
for j in range(i + 1, words.len - 1)
pairs.push([words[i], words[j]])
end for
end for
return pairs
end function
 
isReversed = function(word1, word2)
for i in range(0, word1.len - 1)
if word1[i] != word2[-(i+1)] then return false
end for
return true
end function
 
makeKey = function(word)
return word.split("").sort.join("")
end function
 
wordList = http.get("https://raw.githubusercontent.com/dwyl/english-words/master/words.txt").split(char(10))
 
wordSets = {}
 
for word in wordList
k = makeKey(word)
if not wordSets.hasIndex(k) then
wordSets[k] = [word]
else
wordSets[k].push(word)
end if
end for
 
anadromes = []
for wordSet in wordSets.values
if wordSet.len > 1 and wordSet[0].len > 6 then
pairs = getPairs(wordSet)
for pair in pairs
if isReversed(pair[0], pair[1]) then print pair
end for
end if
end for
</syntaxhighlight>
{{out}}
<pre>["amaroid", "diorama"]
["degener", "reneged"]
["deifier", "reified"]
["deliver", "reviled"]
["deviler", "relived"]
["dessert", "tressed"]
["desserts", "stressed"]
["dioramas", "samaroid"]
["gateman", "nametag"]
["leveler", "relevel"]
["relever", "reveler"]
["revotes", "setover"]
["pat-pat", "tap-tap"]
["redrawer", "rewarder"]
["reknits", "stinker"]
["reliver", "reviler"]
["sallets", "stellas"]
</pre>
 
Anonymous user