You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/2015/rust/src/day_04.rs

28 lines
520 B

use crypto::md5::Md5;
use crypto::digest::Digest;
pub fn solve(input: &str) -> i32 {
let mut md5 = Md5::new();
let key = input.as_bytes();
let mut i = 0;
let mut out = [0; 16];
loop {
i += 1;
md5.input(key);
md5.input(i.to_string().as_bytes());
md5.result(&mut out);
if out[0] == 0 && out[1] == 0 && out[2] == 0 {
break;
}
md5.reset();
}
i
}
#[test]
#[ignore]
fn test_day04() {
assert_eq!(609043, solve("abcdef"));
}