This process only needs to identify 1 word in the list that meets the criteria resulting in a unique list of the words that were contained within other words.
Then add a single line to my solution above and it should reduce the time taken by roughly a factor of 10. Ie. A projected 1 hour:
#! perl -slw use strict; my @words = do{ local @ARGV = 'words.txt'; <> }; chomp @words; my $all = join ' ', @words; my $start = time; my $n = 0; for my $i ( @words ) { for my $j ( $all =~ m[ ([^ ]*$i[^ ]*) ]g ) { next if $j eq $i or $j eq "${i}s" or $j eq "${i}'s"; print "$j contains $i"; last; ## Added } } printf STDERR "Took %d seconds for %d words\n", time() - $start, scalar @words;
In reply to Re^5: Words in Words
by BrowserUk
in thread Words in Words
by sarchasm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |