Words from neighbour ones: Difference between revisions

(Words from neighbour ones en Yabasic)
Line 728:
</pre>
 
=={{header|jq}}==
 
For speed, this solution constructs a JSON object as a dictionary ($hash):<lang jq>
# input: the dictionary
# $n: starting point (starting at 0)
# $hash: the hashed dictionary
def form_word($n; $hash):
. as $dict
| (reduce range(0;9) as $i (""; . + $dict[$n+$i][$i: $i+1] )) as $word
| if $hash[$word] then $word else empty end;
[inputs | select(length >= 9)]
| (reduce .[] as $x ({}; .[$x]=true)) as $hash
| [range(0; length-9) as $i | form_word($i; $hash)]</lang>
 
{{out}}
<pre>["applicate","architect","astronomy","christine","christoph","committee","committee","committee","committee","committee","composite","constrict","constrict","construct","different","extensive","greenwood","implement","improvise","intercept","interpret","interrupt","interrupt","philosoph","prescript","receptive","telephone","transcend","transcend","transport","transpose"]
</pre>
=={{header|Julia}}==
<lang julia>function wordsfromneighbourones(wordfile::String, len = 9, colwidth = 11, numcols = 8)
2,485

edits