summaryrefslogtreecommitdiff
path: root/aoc5
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2022-04-19 20:22:56 +0200
committerJustin Wernick <justin@worthe-it.co.za>2022-04-19 20:23:15 +0200
commit174772b5b8d9f5bf5e3c8e8152adfd89f0e83f6b (patch)
treea003b748ee939b30a2bcd3caf2378228baa304c1 /aoc5
parentfd75b3fb95ad049b0025cb8fc0b3459b8f872d61 (diff)
Refile for merging repos
Diffstat (limited to 'aoc5')
-rw-r--r--aoc5/Cargo.lock12
-rw-r--r--aoc5/Cargo.toml7
-rw-r--r--aoc5/src/main.rs49
3 files changed, 0 insertions, 68 deletions
diff --git a/aoc5/Cargo.lock b/aoc5/Cargo.lock
deleted file mode 100644
index 6d0e69c..0000000
--- a/aoc5/Cargo.lock
+++ /dev/null
@@ -1,12 +0,0 @@
-[root]
-name = "aoc5"
-version = "0.1.0"
-dependencies = [
- "md5 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "md5"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
diff --git a/aoc5/Cargo.toml b/aoc5/Cargo.toml
deleted file mode 100644
index cc09c3c..0000000
--- a/aoc5/Cargo.toml
+++ /dev/null
@@ -1,7 +0,0 @@
-[package]
-name = "aoc5"
-version = "0.1.0"
-authors = ["Justin Worthe <justin.worthe@entelect.co.za>"]
-
-[dependencies]
-md5 = "^0.2" \ No newline at end of file
diff --git a/aoc5/src/main.rs b/aoc5/src/main.rs
deleted file mode 100644
index 31bef5e..0000000
--- a/aoc5/src/main.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-extern crate md5;
-
-fn main() {
- let room = "reyedfim";
-
- let mut i = 0;
- let mut found_bytes = 0;
-
- let mut code: [Option<u8>; 8] = [None;8];
-
- println!("Cracking the passwordz");
- print_code(&code);
-
- while found_bytes < 8 {
- let room_string = format!("{}{}", room, i);
- let room_bytes = room_string.into_bytes();
- let hash = md5::compute(room_bytes.as_slice());
- if match_hash(hash) {
- let position = hash[2];
- let value = hash[3] / 16;
- if code[position as usize].is_none() {
- code[position as usize] = Some(value);
- print_code(&code);
- found_bytes += 1;
- }
- }
-
- i+=1;
- }
-
- println!("Password found!");
-}
-
-fn match_hash(hash: [u8; 16]) -> bool {
- hash[0] == 0 &&
- hash[1] == 0 &&
- hash[2] < 8
-}
-
-fn print_code(code: &[Option<u8>; 8]) {
- println!("");
- for &byte in code.iter() {
- match byte {
- None => {print!("-");},
- Some(x) => {print!("{:x}", x);}
- }
- }
- println!("");
-}