aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-202/ealvar3z/README2
-rw-r--r--challenge-202/ealvar3z/blog.txt1
-rw-r--r--challenge-202/ealvar3z/rust/.gitignore3
-rw-r--r--challenge-202/ealvar3z/rust/src/main.rs63
4 files changed, 1 insertions, 68 deletions
diff --git a/challenge-202/ealvar3z/README b/challenge-202/ealvar3z/README
index d35a294b26..a50c065308 100644
--- a/challenge-202/ealvar3z/README
+++ b/challenge-202/ealvar3z/README
@@ -1 +1 @@
-Solution by ealvar3z. Run `cargo test` to check them.
+Solution by ealvar3z
diff --git a/challenge-202/ealvar3z/blog.txt b/challenge-202/ealvar3z/blog.txt
deleted file mode 100644
index c849c43be3..0000000000
--- a/challenge-202/ealvar3z/blog.txt
+++ /dev/null
@@ -1 +0,0 @@
-https://eax.bearblog.dev/perl-weekly-challenge-205/
diff --git a/challenge-202/ealvar3z/rust/.gitignore b/challenge-202/ealvar3z/rust/.gitignore
deleted file mode 100644
index 9a30948bdd..0000000000
--- a/challenge-202/ealvar3z/rust/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/target
-Cargo.toml
-Cargo.lock
diff --git a/challenge-202/ealvar3z/rust/src/main.rs b/challenge-202/ealvar3z/rust/src/main.rs
deleted file mode 100644
index 0a38c837a5..0000000000
--- a/challenge-202/ealvar3z/rust/src/main.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- pub fn test_task_one() {
- let a = [5,3,4];
- let b = [5,6];
- let c = [5,4,4,3];
-
- assert_eq!(task_one(&a), 3);
- assert_eq!(task_one(&b), 6);
- assert_eq!(task_one(&c), 3);
- }
-
- #[test]
- pub fn test_task_two() {
- let a = [1,2,3,4,5,6,7];
- let b = [2,4,1,3];
- let c = [10,5,7,12,8];
-
- assert_eq!(task_two(&a), 7);
- assert_eq!(task_two(&b), 7);
- assert_eq!(task_two(&c), 15);
- }
-}
-
-pub fn task_one(arr: &[i32]) -> i32 {
- let highest = arr.iter().max().cloned().unwrap_or_default();
- let x = arr.iter().filter(|&i| *i != highest);
- let snd_highest = x.clone().max().cloned().unwrap_or_default();
- let third_highest = x.filter(|&i| *i != snd_highest);
- return *third_highest.max().unwrap_or(&highest);
-}
-
-pub fn task_two(arr: &[i32]) -> i32 {
- arr.iter()
- .enumerate()
- .fold(0, |max_xor, (i, &x)| {
- arr[i+1..]
- .iter()
- .fold(max_xor, |max_xor, &y| {
- let xor = x ^ y;
- return xor.max(max_xor)
- })
- })
-}
-
-fn main() {
- #[cfg(test)]
- mod test_runner {
- use super::tests;
-
- pub fn run() {
- tests::test_task_one();
- tests::test_task_two();
- }
- }
-
- #[cfg(test)]
- test_runner::run();
-}
-