Find words with alternating vowels and consonants: Difference between revisions
Content deleted Content added
added Perl programming solution |
|||
Line 366: | Line 366: | ||
verisimilitude |
verisimilitude |
||
</pre> |
</pre> |
||
Rosetta Code |
|||
Hkdtam Talk Preferences Watchlist Contributions Log out |
|||
Search |
|||
Community |
|||
Explore |
|||
Page Discussion |
|||
Edit History |
|||
Move Unwatch Refresh |
|||
I'm working on modernizing Rosetta Code's infrastructure. Starting with communications. Please accept this time-limited open invite to RC's Slack.. --Michael Mol (talk) 20:59, 30 May 2020 (UTC) |
|||
Editing Process SMIL directives in XML data (section) |
|||
=={{header|Perl}}== |
|||
Used [https://metacpan.org/pod/App::a2p a2p]. |
|||
{{trans|AWK}} |
|||
<lang Perl># 20210104 added Perl programming solution |
|||
use strict; |
|||
use warnings; |
|||
my $alternatingCount = 0; |
|||
while (<>) { |
|||
(my $Fld1) = split(' ', $_, -1); |
|||
if ((length($Fld1) >= 10)) { # have an arpropriate length word |
|||
my $word = $Fld1; |
|||
my $haveVowel = $word =~ /^[aeiou]/; |
|||
my $isAlternating = 1; |
|||
for (my $wPos = 2; $isAlternating && $wPos <= length($word); $wPos++) { |
|||
my $hadVowel = $haveVowel; |
|||
$haveVowel = substr($word, ($wPos)-1, 1) =~ /^[aeiou]/; |
|||
$isAlternating = ($hadVowel && !$haveVowel) || (!$hadVowel && $haveVowel); |
|||
} # for wPos |
|||
if ($isAlternating) { |
|||
printf ' %16s%s', $word, ($alternatingCount % 6 == 5) ? "\n" : ''; |
|||
$alternatingCount += 1; |
|||
} # if isAlternating |
|||
} |
|||
} |
|||
printf "\n%d words with alternating vowels and consonants found\n", $alternatingCount;</lang> |
|||
{{out}} |
|||
<pre> |
|||
aboriginal apologetic bimolecular borosilicate calorimeter capacitate |
|||
capacitive capitoline capitulate caricature colatitude coloratura |
|||
colorimeter debilitate decelerate decolonize definitive degenerate |
|||
deliberate demodulate denominate denotative deregulate desiderata |
|||
desideratum dilapidate diminutive epigenetic facilitate hemosiderin |
|||
heretofore hexadecimal homogenate inoperative judicature latitudinal |
|||
legitimate lepidolite literature locomotive manipulate metabolite |
|||
nicotinamide oratorical paragonite pejorative peridotite peripatetic |
|||
polarimeter recitative recuperate rehabilitate rejuvenate remunerate |
|||
repetitive reticulate savonarola similitude solicitude tananarive |
|||
telekinesis teratogenic topologize unilateral unimodular uninominal |
|||
verisimilitude |
|||
67 words with alternating vowels and consonants found</pre> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |