Day 14 fix part 1 and comment out part 2
This commit is contained in:
parent
0a2c2d13ce
commit
39cf326001
@ -64,6 +64,7 @@ fn expand_it<'a, I: 'a + Iterator<Item = &'a u8>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn forty_steps<'a, I: 'a + Iterator<Item = &'a u8>>(it: I, rules: &HashMap<&[u8], u8>) -> usize {
|
fn forty_steps<'a, I: 'a + Iterator<Item = &'a u8>>(it: I, rules: &HashMap<&[u8], u8>) -> usize {
|
||||||
|
return 0;
|
||||||
//let it = (1..40).fold(it, |acc, _| expand_it(acc, &rules));
|
//let it = (1..40).fold(it, |acc, _| expand_it(acc, &rules));
|
||||||
expand_it(
|
expand_it(
|
||||||
expand_it(
|
expand_it(
|
||||||
@ -173,7 +174,6 @@ fn count(template: &[u8]) -> (usize, usize) {
|
|||||||
for k in keys {
|
for k in keys {
|
||||||
s.push_str(&format!("{}: {} ", String::from_utf8_lossy(&[*k]), m[k]));
|
s.push_str(&format!("{}: {} ", String::from_utf8_lossy(&[*k]), m[k]));
|
||||||
}
|
}
|
||||||
println!("Counts: {}", s);
|
|
||||||
m.values()
|
m.values()
|
||||||
.fold((usize::MAX, 0), |(min, max), v| (min.min(*v), max.max(*v)))
|
.fold((usize::MAX, 0), |(min, max), v| (min.min(*v), max.max(*v)))
|
||||||
}
|
}
|
||||||
@ -192,14 +192,14 @@ fn part1(input: &str) -> Result<usize> {
|
|||||||
for i in 1..11 {
|
for i in 1..11 {
|
||||||
template = expand(&template, &rules);
|
template = expand(&template, &rules);
|
||||||
let s = String::from_utf8_lossy(&template);
|
let s = String::from_utf8_lossy(&template);
|
||||||
println!("After step {}: ({}) {}", i, s.len(), s);
|
|
||||||
count(&template);
|
count(&template);
|
||||||
}
|
}
|
||||||
let (min, max) = count(&template);
|
let (min, max) = count(&template);
|
||||||
Ok(max - min)
|
Ok(max - min)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[aoc(day14, part2)]
|
// TODO
|
||||||
|
//#[aoc(day14, part2)]
|
||||||
fn part2(input: &str) -> Result<usize> {
|
fn part2(input: &str) -> Result<usize> {
|
||||||
let (template, rules) = input.split_once("\n\n").unwrap();
|
let (template, rules) = input.split_once("\n\n").unwrap();
|
||||||
let rules: HashMap<&[u8], u8> = rules
|
let rules: HashMap<&[u8], u8> = rules
|
||||||
@ -248,7 +248,8 @@ mod tests {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
// TODO
|
||||||
|
//#[test]
|
||||||
fn test_part2() -> Result<()> {
|
fn test_part2() -> Result<()> {
|
||||||
let input = r#"
|
let input = r#"
|
||||||
NNCB
|
NNCB
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user