aboutsummaryrefslogtreecommitdiff
path: root/challenge-053/dave-jacoby/rust
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/rust
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/rust')
-rw-r--r--challenge-053/dave-jacoby/rust/ch-2.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/challenge-053/dave-jacoby/rust/ch-2.rs b/challenge-053/dave-jacoby/rust/ch-2.rs
new file mode 100644
index 0000000000..086987ff5b
--- /dev/null
+++ b/challenge-053/dave-jacoby/rust/ch-2.rs
@@ -0,0 +1,51 @@
+fn main() {
+ let my_str = "".to_string();
+ vowel_strings(2,my_str);
+}
+
+fn vowel_strings ( max_len:i32 , my_str:String) -> bool {
+ let rts_ym : String = my_str.chars().rev().collect();
+ let my_len = my_str.len();
+ let mut last = "";
+ let mut vnext : Vec<String> = Vec::new();
+
+ if max_len as usize == my_len {
+ println!("{}",my_str);
+ return true
+ }
+
+ if my_len > 0 {
+ last = &rts_ym[0..1];
+ }
+
+ if last == "a" {
+ vnext.push("e".to_string());
+ vnext.push("i".to_string());
+ } else if last == "e" {
+ vnext.push("i".to_string());
+ } else if last == "i" {
+ vnext.push("a".to_string());
+ vnext.push("e".to_string());
+ vnext.push("o".to_string());
+ vnext.push("u".to_string());
+ } else if last == "o" {
+ vnext.push("a".to_string());
+ vnext.push("o".to_string());
+ } else if last == "u" {
+ vnext.push("e".to_string());
+ vnext.push("o".to_string());
+ } else {
+ vnext.push("a".to_string());
+ vnext.push("e".to_string());
+ vnext.push("i".to_string());
+ vnext.push("o".to_string());
+ vnext.push("u".to_string());
+
+ }
+
+ for next in &vnext {
+ let next_str = format!("{}{}",my_str,next);
+ vowel_strings(max_len,next_str);
+ }
+ true
+} \ No newline at end of file