aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-03-23 09:35:28 +0000
committerGitHub <noreply@github.com>2020-03-23 09:35:28 +0000
commit355ad7161ff0e20d092208a62efec7bb92f52ce0 (patch)
tree334e0ca9302a783a6f68b419fd5a61e3d167b91a
parent9e699f1de363d106aa7069e6057f6342796aadb4 (diff)
parent8945c5ce026a308645b4cce1b45ff1843722f058 (diff)
downloadperlweeklychallenge-club-355ad7161ff0e20d092208a62efec7bb92f52ce0.tar.gz
perlweeklychallenge-club-355ad7161ff0e20d092208a62efec7bb92f52ce0.tar.bz2
perlweeklychallenge-club-355ad7161ff0e20d092208a62efec7bb92f52ce0.zip
Merge pull request #1450 from Doomtrain14/master
Added perl solution for ch#53-2
-rw-r--r--challenge-053/yet-ebreo/perl/ch-2.pl54
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