Word wheel: Difference between revisions

(Added Quackery.)
Line 1,724:
wok
woke</pre>
 
=={{header|jq}}==
{{works with|jq}}
'''Also works with gojq, the Go implementation of jq, and with fq'''
<syntaxhighlight lang=jq>
# remove words with fewer than 3 or more than 9 letters
def words: inputs | select(length | . > 2 and . < 10);
 
# The central letter in `puzzle` should be the central letter of the word wheel
def solve(puzzle):
def chars: explode[] | [.] | implode;
(puzzle | .[ (length - 1) / 2]) as $central
| [ words
| select( index($central) and
first( foreach (chars, null) as $c (
{ letters: puzzle, ok: null };
if $c == null then .ok = true
else (.letters|index($c)) as $ix
| if $ix == null
then .ok = false
else .letters |= del(.[$ix])
end
end;
select(.ok != null).ok ) ) ) ];
 
solve(["d", "e", "e", "g", "k", "l", "n", "o", "w"])
| "The following \(length) words are the solutions to the puzzle:", .[]
</syntaxhighlight>
'''Invocation''': < unixdict.txt jq -Rnr -f word-wheel.jq
{{output}}
<pre>
The following 17 words are the solutions to the puzzle:
eke
elk
keel
keen
keg
ken
keno
knee
kneel
knew
know
knowledge
kong
leek
week
wok
woke
</pre>
 
 
=={{header|Julia}}==
Line 1,767 ⟶ 1,818:
["eke", "elk", "keel", "keen", "keg", "ken", "keno", "knee", "kneel", "knew", "know", "knowledge", "kong", "leek", "week", "wok", "woke"]
</pre>
 
=={{header|Lua}}==
<syntaxhighlight lang="lua">LetterCounter = {
2,442

edits