@@ -24,23 +24,21 @@ fn read_input() -> (Vec<Vec<char>>, Vec<Cart>) {
|
||||
for (x, c) in line.chars().enumerate() {
|
||||
if tiles.contains(&c) {
|
||||
map[x][y] = c;
|
||||
} else {
|
||||
if c != ' ' {
|
||||
map[x][y] = match c {
|
||||
'>' => '-',
|
||||
'<' => '-',
|
||||
'^' => '-',
|
||||
'v' => '-',
|
||||
_ => panic!("{} is invalid input char at this point", c),
|
||||
};
|
||||
carts.push(Cart {
|
||||
x,
|
||||
y,
|
||||
direction: c,
|
||||
intersections_visited: 0,
|
||||
active: true,
|
||||
});
|
||||
}
|
||||
} else if c != ' ' {
|
||||
map[x][y] = match c {
|
||||
'>' => '-',
|
||||
'<' => '-',
|
||||
'^' => '-',
|
||||
'v' => '-',
|
||||
_ => panic!("{} is invalid input char at this point", c),
|
||||
};
|
||||
carts.push(Cart {
|
||||
x,
|
||||
y,
|
||||
direction: c,
|
||||
intersections_visited: 0,
|
||||
active: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +55,7 @@ struct Cart {
|
||||
active: bool,
|
||||
}
|
||||
|
||||
fn perform_round(map: &Vec<Vec<char>>, carts: &mut Vec<Cart>) {
|
||||
fn perform_round(map: &[Vec<char>], carts: &mut Vec<Cart>) {
|
||||
carts.sort_unstable_by(|a, b| {
|
||||
if a.y == b.y {
|
||||
a.x.cmp(&b.x)
|
||||
|
||||
Reference in New Issue
Block a user