http://www.perlmonks.org?node_id=11147758


in reply to Words, no consecutive doubled letters but repeated letters

Solving this sort of problem can be made much easier if you break it into parts. Use a simple regex to drop words containing doubled letters then you can use a simple regex to find repeated letters.

use warnings; use strict; my %words = map {$_ => 1} split ' ', "This will search for words with +doubled letters at positions"; print "$_\n" for grep {!/(\w)\1/ && /(\w).+\1/} sort keys %words;

Prints:

doubled positions
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond