diff options
| author | Ysmael Ebreo <Ysmael.Ebreo@latticesemi.com> | 2020-03-23 17:32:07 +0800 |
|---|---|---|
| committer | Ysmael Ebreo <Ysmael.Ebreo@latticesemi.com> | 2020-03-23 17:32:07 +0800 |
| commit | 8945c5ce026a308645b4cce1b45ff1843722f058 (patch) | |
| tree | e036934176be1fa420a2d9de7d9b4656af6e2aff | |
| parent | b7df223b5553fed99664ec4f80448b2f408eb131 (diff) | |
| download | perlweeklychallenge-club-8945c5ce026a308645b4cce1b45ff1843722f058.tar.gz perlweeklychallenge-club-8945c5ce026a308645b4cce1b45ff1843722f058.tar.bz2 perlweeklychallenge-club-8945c5ce026a308645b4cce1b45ff1843722f058.zip | |
Added perl solution for ch#53-2
| -rw-r--r-- | challenge-053/yet-ebreo/perl/ch-2.pl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/challenge-053/yet-ebreo/perl/ch-2.pl b/challenge-053/yet-ebreo/perl/ch-2.pl new file mode 100644 index 0000000000..01d5273f46 --- /dev/null +++ b/challenge-053/yet-ebreo/perl/ch-2.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl +use strict; +use warnings; +use feature 'say'; + +# Write a script to accept an integer 1 <= N <= 5 that would print all possible strings of size N formed by using only vowels (a, e, i, o, u). +# The string should follow the following rules: +# ‘a’ can only be followed by ‘e’ and ‘i’. +# ‘e’ can only be followed by ‘i’. +# ‘i’ can only be followed by ‘a’, ‘e’, ‘o’, and ‘u’. +# ‘o’ can only be followed by ‘a’ and ‘u’. +# ‘u’ can only be followed by ‘o’ and ‘e’. +# For example, if the given integer N = 2 then script should print the following strings: +# ae +# ai +# ei +# ia +# io +# iu +# ie +# oa +# ou +# uo +# ue + +#One liner solution. I believe the conditions can be simplified, but I decided to keep it this way so that it +#Clearly reflects the conditions mentioned in the task description +!(/a[^ei]/ || /e[^i]/ || /i[^aeou]/ || /o[^au]/ || /u[^oe]/) && say for glob "{a,e,i,o,u}" x ($ARGV[0]||1); +=begin +perl .\ch-2.pl 3 +aei +aia +aie +aio +aiu +eia +eie +eio +eiu +iae +iai +iei +ioa +iou +iue +iuo +oae +oai +oue +ouo +uei +uoa +uou +=cut
\ No newline at end of file |
