aboutsummaryrefslogtreecommitdiff
path: root/challenge-254/zapwai/rust/ch-2.rs
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-254/zapwai/rust/ch-2.rs')
-rw-r--r--challenge-254/zapwai/rust/ch-2.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/challenge-254/zapwai/rust/ch-2.rs b/challenge-254/zapwai/rust/ch-2.rs
new file mode 100644
index 0000000000..a6b341a374
--- /dev/null
+++ b/challenge-254/zapwai/rust/ch-2.rs
@@ -0,0 +1,39 @@
+fn main() {
+ let words = ["Raku", "Perl", "Julia", "Uaia"];
+ for w in words {
+ proc(w);
+ }
+}
+
+fn proc(word : &str) {
+ let mut vows = Vec::new();
+ let mut inds = Vec::new();
+ let mut w = Vec::new();
+ for c in word.chars() {
+ w.push(c);
+ }
+ for i in 0 .. word.len() {
+ let l = w[i];
+ if l == 'a' || l == 'A' ||
+ l == 'e' || l == 'E' ||
+ l == 'i' || l == 'I' ||
+ l == 'o' || l == 'O' ||
+ l == 'u' || l == 'U'
+ {
+ vows.push(l);
+ inds.push(i);
+ }
+ }
+ inds.push(0);
+ let k = vows.len()-1;
+ let mut j = 0;
+ for i in 0 .. word.len() {
+ if i == inds[j] {
+ print!("{}", vows[k-j]);
+ j += 1;
+ } else {
+ print!("{}", w[i]);
+ }
+ }
+ println!("");
+} \ No newline at end of file