in reply to Nonrepeating characters in an RE
OUTPUT:#!/usr/bin/perl -l use warnings; use strict; my $template = 'neocene'; my $uniq = 4; my $len = length $template; my @dict; @dict = <>; # <-- 354984si.ngl chomp @dict; my @good = grep { my %occ1; while( $template =~ m/./g ){ my $key = $& . substr $_, $-[0], 1; $occ1{ $key } ++; } my %occ2; map $occ2{ $_ } ++, map { ( split '' )[ 1 ] } keys %occ1; $uniq == keys %occ1 and $uniq == keys %occ2; } grep $len == length, @dict; print for @good;
UPD.removed mistakenly added word from the output which is absent in the dictionary.kaitaka lauhala metreme neocene tempete
|
---|