Words from neighbour ones: Difference between revisions
Reordered Python and Raku, added output clarification
(Added header) |
(Reordered Python and Raku, added output clarification) |
||
Line 1,108:
transport
transpose</pre>
=={{header|Raku}}==▼
<lang perl6>my @words_ge_9 = 'unixdict.txt'.IO.lines.grep( *.chars >= 9 );▼
my %words_eq_9 = @words_ge_9 .grep( *.chars == 9 ).Set;▼
my @new_words = gather for @words_ge_9.rotor( 9 => -8 ) -> @nine_words {▼
my $new_word = [~] map { @nine_words[$_].substr($_, 1) }, ^9;▼
take $new_word if %words_eq_9{$new_word};▼
}▼
.say for unique @new_words;</lang>▼
{{out}}▼
<pre>▼
applicate▼
architect▼
astronomy▼
christine▼
christoph▼
committee▼
composite▼
constrict▼
construct▼
different▼
extensive▼
greenwood▼
implement▼
improvise▼
intercept▼
interpret▼
interrupt▼
philosoph▼
prescript▼
receptive▼
telephone▼
transcend▼
transport▼
transpose▼
</pre>▼
Line 1,174 ⟶ 1,135:
</lang>
{{Output}}
Yes, there are duplicates, the task doesn't say that only unique elements should be present, hence the complete raw list will appear as below :
<pre>
applicate
Line 1,203 ⟶ 1,165:
telephone
transcend
▲transcend
▲transport
▲transpose
▲</pre>
▲=={{header|Raku}}==
▲<lang perl6>my @words_ge_9 = 'unixdict.txt'.IO.lines.grep( *.chars >= 9 );
▲my %words_eq_9 = @words_ge_9 .grep( *.chars == 9 ).Set;
▲my @new_words = gather for @words_ge_9.rotor( 9 => -8 ) -> @nine_words {
▲ my $new_word = [~] map { @nine_words[$_].substr($_, 1) }, ^9;
▲ take $new_word if %words_eq_9{$new_word};
▲}
▲.say for unique @new_words;</lang>
▲{{out}}
▲<pre>
▲applicate
▲architect
▲astronomy
▲christine
▲christoph
▲committee
▲composite
▲constrict
▲construct
▲different
▲extensive
▲greenwood
▲implement
▲improvise
▲intercept
▲interpret
▲interrupt
▲philosoph
▲prescript
▲receptive
▲telephone
transcend
transport
|