mirror of
https://github.com/RussellChamp/advent-of-code-2025-cursor.git
synced 2026-10-27 23:52:34 +00:00
Format code with cargo fmt
This commit is contained in:
1 parent
d3bc3493ee
commit
6f492ae3a1
3 files changed
+22
-5
No files matched your search
+10
-2
@@ -19,7 +19,11 @@ fn generate_invalid_part1(min: u64, max: u64) -> Vec<u64> {
|
||||
|
||||
// Pattern length k produces numbers with 2k digits
|
||||
for pattern_len in 1..=max_digits / 2 {
|
||||
let pattern_min = if pattern_len == 1 { 1 } else { 10u64.pow(pattern_len as u32 - 1) };
|
||||
let pattern_min = if pattern_len == 1 {
|
||||
1
|
||||
} else {
|
||||
10u64.pow(pattern_len as u32 - 1)
|
||||
};
|
||||
let pattern_max = 10u64.pow(pattern_len as u32) - 1;
|
||||
|
||||
for pattern in pattern_min..=pattern_max {
|
||||
@@ -40,7 +44,11 @@ fn generate_invalid_part2(min: u64, max: u64) -> Vec<u64> {
|
||||
|
||||
// For each pattern length
|
||||
for pattern_len in 1..=max_digits / 2 {
|
||||
let pattern_min = if pattern_len == 1 { 1 } else { 10u64.pow(pattern_len as u32 - 1) };
|
||||
let pattern_min = if pattern_len == 1 {
|
||||
1
|
||||
} else {
|
||||
10u64.pow(pattern_len as u32 - 1)
|
||||
};
|
||||
let pattern_max = 10u64.pow(pattern_len as u32) - 1;
|
||||
let multiplier = 10u64.pow(pattern_len as u32);
|
||||
|
||||
|
||||
+8
-2
@@ -33,7 +33,10 @@ pub fn part_one(input: &str) -> Option<u64> {
|
||||
}
|
||||
|
||||
// Convert line to digits
|
||||
let digits: Vec<u8> = line.chars().map(|c| c.to_digit(10).unwrap() as u8).collect();
|
||||
let digits: Vec<u8> = line
|
||||
.chars()
|
||||
.map(|c| c.to_digit(10).unwrap() as u8)
|
||||
.collect();
|
||||
total += max_joltage_2(&digits);
|
||||
}
|
||||
|
||||
@@ -77,7 +80,10 @@ pub fn part_two(input: &str) -> Option<u64> {
|
||||
continue;
|
||||
}
|
||||
|
||||
let digits: Vec<u8> = line.chars().map(|c| c.to_digit(10).unwrap() as u8).collect();
|
||||
let digits: Vec<u8> = line
|
||||
.chars()
|
||||
.map(|c| c.to_digit(10).unwrap() as u8)
|
||||
.collect();
|
||||
total += max_joltage_k(&digits, 12);
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -41,7 +41,10 @@ fn count_neighbors(grid: &[Vec<Cell>], row: usize, col: usize) -> usize {
|
||||
}
|
||||
let nr = row as i32 + dr;
|
||||
let nc = col as i32 + dc;
|
||||
if nr >= 0 && nr < rows && nc >= 0 && nc < cols
|
||||
if nr >= 0
|
||||
&& nr < rows
|
||||
&& nc >= 0
|
||||
&& nc < cols
|
||||
&& grid[nr as usize][nc as usize].is_paper()
|
||||
{
|
||||
count += 1;
|
||||
|
||||
Reference in new issue
Block a user