Skip to content

Commit

Permalink
misc: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Quan ZHOU authored and Quan ZHOU committed Dec 14, 2024
1 parent 8279e1b commit 1f7e8fe
Show file tree
Hide file tree
Showing 3 changed files with 327 additions and 22 deletions.
308 changes: 308 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions day11/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fn apply_rule(n: usize) -> Vec<usize> {

let (first_half, second_half) = n_str.split_at(mid);
vec![first_half.parse().unwrap(), second_half.parse().unwrap()]
},
_ => vec![n * 2024]
}
_ => vec![n * 2024],
}
}

Expand All @@ -36,7 +36,8 @@ fn rec(stones: Vec<usize>, blinks_left: usize) -> usize {
}

fn part1(input: &str, n: usize) -> usize {
let init: Vec<usize> = input.split_whitespace()
let init: Vec<usize> = input
.split_whitespace()
.map(|n| n.parse::<usize>().unwrap())
.collect();
let mut blink = init;
Expand All @@ -47,7 +48,8 @@ fn part1(input: &str, n: usize) -> usize {
}

fn part2(input: &str, n: usize) -> usize {
let init: Vec<usize> = input.split_whitespace()
let init: Vec<usize> = input
.split_whitespace()
.map(|n| n.parse::<usize>().unwrap())
.collect();
rec(init, n)
Expand All @@ -62,10 +64,8 @@ mod tests {
fn test_part1() {
assert_eq!(part1("125 17", 6), 22);
assert_eq!(part1("125 17", 25), 55312);

}


#[test]
fn test_part2() {
assert_eq!(part2("125 17", 75), 65601038650482);
Expand Down
Loading

0 comments on commit 1f7e8fe

Please sign in to comment.