Download or view factorableWords.frink in plain text format
/** This finds words expressed in base 36 that are factorable into other words. Yeah, I know, it's silly. */
words = "file:///home/eliasen/prog/mobydict/scrabble/sowpods.txt"
wordList = select[lc[lines[words]], %r/^[a-z]*$/i]
wordSet = toSet[wordList]
for word = wordList
{
if (length[result = factorWord[word, wordSet]] != 0)
println["$word\t$result"]
}
/** This function sets up the recursive call. All results will be put in the
set. */
factorWord[word, wordSet] :=
{
return factorWord[word, wordSet, new set]
}
/** This is the actual recursive call. Results will be returned in the return
value, which is the set called result. */
factorWord[word, wordSet, result] :=
{
num = parseInt[word, 36]
factors = allFactors[num, false, false, false]
for factor = factors
if wordSet.contains[factor -> base36]
{
other = (num/factor -> base36)
if (wordSet.contains[other])
result.put[other]
else
factorWord[other, wordSet, result]
}
return result
}
Download or view factorableWords.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 20218 days, 0 hours, 15 minutes ago.