aboutsummaryrefslogtreecommitdiff
path: root/challenge-053/dave-jacoby/node
diff options
context:
space:
mode:
authorDave Jacoby <jacoby.david@gmail.com>2020-03-23 19:41:11 -0400
committerDave Jacoby <jacoby.david@gmail.com>2020-03-23 19:41:11 -0400
commit7bb009b65541c03e71468b4917b9a098f1fbbba7 (patch)
tree8c812d0717e4be254d74370f5eb4bab2b91cda4c /challenge-053/dave-jacoby/node
parent4c1c768bd12a75480fa4d4c5cfe70ac861b21e9b (diff)
downloadperlweeklychallenge-club-7bb009b65541c03e71468b4917b9a098f1fbbba7.tar.gz
perlweeklychallenge-club-7bb009b65541c03e71468b4917b9a098f1fbbba7.tar.bz2
perlweeklychallenge-club-7bb009b65541c03e71468b4917b9a098f1fbbba7.zip
I solved task 2 first and got confused
Diffstat (limited to 'challenge-053/dave-jacoby/node')
-rw-r--r--challenge-053/dave-jacoby/node/ch-2.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-053/dave-jacoby/node/ch-2.js b/challenge-053/dave-jacoby/node/ch-2.js
new file mode 100644
index 0000000000..b0cd5fa3c6
--- /dev/null
+++ b/challenge-053/dave-jacoby/node/ch-2.js
@@ -0,0 +1,35 @@
+#!/usr/bin/env node
+
+vowel_strings(2);
+
+function vowel_strings(max_len, str = '') {
+ if (str.length === max_len) {
+ console.log(str);
+ return;
+ }
+ var next = [];
+ var last = '';
+
+ if (str.length > 0) {
+ last = str.substring(-1, 1);
+ }
+
+ if (str === '') {
+ next = ['a', 'e', 'i', 'o', 'u'];
+ } else if (last === 'a') {
+ next = ['e', 'i'];
+ } else if (last === 'e') {
+ next = ['i'];
+ } else if (last === 'i') {
+ next = ['a', 'e', 'o', 'u'];
+ } else if (last === 'o') {
+ next = ['a', 'u'];
+ } else if (last === 'u') {
+ next = ['e', 'o'];
+ }
+
+ const iter = next.values();
+ for (const i of iter) {
+ vowel_strings(max_len, str + i);
+ }
+}