Please don’t rely on this Gitea instance being around forever. If any of your build scripts use my (kageru’s) projects hosted here, check my Github or IEW on Github for encoding projects. If you can’t find what you’re looking for there, tell me to migrate it.

Fixed the bug with the manhattan norm, day6 part1 now working

master
attila 4 years ago
parent 940ccdedbb
commit 0c98f72052

@ -31,11 +31,11 @@ fn main() {
for j in min_y..(max_y+1) {
let mut winning_x = 0;
let mut winning_y = 0;
let mut min_dist = std::i32::MAX;
let mut second_min_dist = std::i32::MAX;
let mut min_dist = std::i32::MAX;
for (x,y) in &anchorpoints{
let dist = (x - i + y - j).abs();
let dist = (x - i).abs() + (y - j).abs();
if dist < min_dist{
min_dist = dist;
@ -47,19 +47,17 @@ fn main() {
}
if min_dist != second_min_dist {
*points_nearest_to_anchor.entry((winning_x,winning_y)).or_insert(1) += 1;
*points_nearest_to_anchor.entry((winning_x,winning_y)).or_insert(0) += 1;
}
}
}
let mut largest_area = 0;
for area in points_nearest_to_anchor.values() {
if *area > largest_area {
largest_area = *area;
for ((x,y), area) in points_nearest_to_anchor {
if area > largest_area && x > min_x && x < max_x && y > min_y && y < max_y {
largest_area = area;
}
println!("{}", *area);
}
println!("{}", largest_area);

Loading…
Cancel
Save