Words from neighbour ones: Difference between revisions

Content added Content deleted
(→‎{{header|Ruby}}: unique words)
Line 1,509: Line 1,509:
<syntaxhighlight lang="ruby">new_word_size = 9
<syntaxhighlight lang="ruby">new_word_size = 9
well_sized = File.readlines("unixdict.txt", chomp: true).reject{|word| word.size < new_word_size}
well_sized = File.readlines("unixdict.txt", chomp: true).reject{|word| word.size < new_word_size}
well_sized.each_cons(new_word_size) do |slice|
list = well_sized.each_cons(new_word_size).filter_map do |slice|
candidate = (0...new_word_size).inject(""){|res, idx| res << slice[idx][idx] }
candidate = (0...new_word_size).inject(""){|res, idx| res << slice[idx][idx] }
puts candidate if well_sized.include?(candidate)
candidate if well_sized.include?(candidate)
end
end
puts list.uniq
</syntaxhighlight>
</syntaxhighlight>
{{out}}
{{out}}
Line 1,520: Line 1,521:
christine
christine
christoph
christoph
committee
committee
committee
committee
committee
committee
composite
composite
constrict
constrict
constrict
construct
construct
Line 1,536: Line 1,532:
intercept
intercept
interpret
interpret
interrupt
interrupt
interrupt
philosoph
philosoph
Line 1,542: Line 1,537:
receptive
receptive
telephone
telephone
transcend
transcend
transcend
transport
transport
transpose
transpose
</pre>
</pre>

=={{header|VBScript}}==
=={{header|VBScript}}==
Run it in CScript.
Run it in CScript.