Download or view anagramQuandary.frink in plain text format
// Program to find words that do not contain all the letters of another word.
// Make a 2-d array
wordList = new array
for len=1 to 50
wordList@len = new array
// Read words into the wordlist.
// The wordlist files are part of the Moby wordlist project, available at:
// http://icon.shef.ac.uk/Moby/
for word = select[lines["file:/home/eliasen/prog/mobydict/mwords/crossword.txt"], %r/^[b-hj-z]{2,}$/]
wordList@(length[word]).push[word]
for i = 50 to 1 step -1
{
println[i]
for w1 = wordList@i
{
found = false
WORD1:
for fewer = 2 to i-1
for w2 = wordList@fewer
if contains[w1, w2]
{
found = true
break WORD1
}
if found == false
println[w1]
}
}
// Returns true if word 1 contains word 2.
contains[word1, word2] :=
{
a1 = chars[word1]
for c2 = chars[word2]
if (a1.removeValue[c2] == false)
return false
return true
}
Download or view anagramQuandary.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20145 days, 7 hours, 11 minutes ago.