aboutsummaryrefslogtreecommitdiff
path: root/challenge-280/zapwai/rust/ch-1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-280/zapwai/rust/ch-1.rs')
-rw-r--r--challenge-280/zapwai/rust/ch-1.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-280/zapwai/rust/ch-1.rs b/challenge-280/zapwai/rust/ch-1.rs
new file mode 100644
index 0000000000..ab82a4d94f
--- /dev/null
+++ b/challenge-280/zapwai/rust/ch-1.rs
@@ -0,0 +1,27 @@
+fn main() {
+ let mystr = "abcddbca";
+ proc(mystr);
+ let mystr2 = "abcd";
+ proc(mystr2);
+ let mystr3 = "abcdabbb";
+ proc(mystr3);
+}
+
+fn proc(mystr : &str) {
+ println!( "Input: mystr");
+ let mut letter : char = '0';
+ let mut gotten : Vec<char> = Vec::new();
+ for l in mystr.chars() {
+ for g in &gotten {
+ if l == *g {
+ letter = l;
+ }
+ }
+ if letter != '0' {
+ break;
+ } else {
+ gotten.push(l);
+ }
+ }
+ println!( "Output: {letter}");
+}