day-11 formated
This commit is contained in:
@@ -92,4 +92,3 @@ mod test {
|
|||||||
assert_eq!(result, "374".to_string());
|
assert_eq!(result, "374".to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ pub fn part2(input: &str, modr: i64) -> String {
|
|||||||
.filter_map(|y| points.get(&(x, y).into()))
|
.filter_map(|y| points.get(&(x, y).into()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if column.is_empty() {
|
if column.is_empty() {
|
||||||
modifier += modr-1;
|
modifier += modr - 1;
|
||||||
}
|
}
|
||||||
for point in column {
|
for point in column {
|
||||||
adjusted_points.insert(*point + I64Vec2::new(modifier, 0));
|
adjusted_points.insert(*point + I64Vec2::new(modifier, 0));
|
||||||
@@ -47,7 +47,7 @@ pub fn part2(input: &str, modr: i64) -> String {
|
|||||||
.filter_map(|x| adjusted_points.get(&(x, y).into()))
|
.filter_map(|x| adjusted_points.get(&(x, y).into()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if row.is_empty() {
|
if row.is_empty() {
|
||||||
modifier += modr-1;
|
modifier += modr - 1;
|
||||||
}
|
}
|
||||||
for point in row {
|
for point in row {
|
||||||
points.insert(*point + I64Vec2::new(0, modifier));
|
points.insert(*point + I64Vec2::new(0, modifier));
|
||||||
@@ -57,8 +57,8 @@ pub fn part2(input: &str, modr: i64) -> String {
|
|||||||
(points
|
(points
|
||||||
.iter()
|
.iter()
|
||||||
.cartesian_product(points.iter())
|
.cartesian_product(points.iter())
|
||||||
.filter_map(|(a, b)| (*a != *b).then_some(*a-*b))
|
.filter_map(|(a, b)| (*a != *b).then_some(*a - *b))
|
||||||
.map(|a| u64::try_from(a.x.abs()+a.y.abs()).unwrap())
|
.map(|a| u64::try_from(a.x.abs() + a.y.abs()).unwrap())
|
||||||
.sum::<u64>()
|
.sum::<u64>()
|
||||||
/ 2)
|
/ 2)
|
||||||
.to_string()
|
.to_string()
|
||||||
@@ -100,4 +100,3 @@ mod test {
|
|||||||
assert_eq!(result, "1030".to_string());
|
assert_eq!(result, "1030".to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user