diff options
| -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 |
