-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday4.rs
41 lines (31 loc) · 911 Bytes
/
day4.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! [Day 4: The Ideal Stocking Stuffer](https://adventofcode.com/2015/day/4)
/// main function
fn main() {
let args = aoc::parse_args();
let data = args.input.trim_ascii().to_string();
let mut key = 0;
loop {
let key_str = key.to_string();
let mut x = data.clone();
x.push_str(&key_str);
let digest = md5::compute(x);
if format!("{digest:x}").starts_with("00000") {
// println!("{}\t{:?}", key, digest);
println!("{key}");
break;
}
key += 1;
}
loop {
let key_str = key.to_string();
let mut x = data.clone();
x.push_str(&key_str);
let digest = md5::compute(x);
if format!("{digest:x}").starts_with("000000") {
// println!("{}\t{:?}", key, digest);
println!("{key}");
break;
}
key += 1;
}
}