day03 task 2 cleanup

This commit is contained in:
Johannes
2019-12-04 20:35:24 +01:00
parent be49fbe161
commit c6bb71b1db

View File

@@ -102,11 +102,9 @@ fn task2(p1: &Vec<&str>, p2: &Vec<&str>) {
}
fn get_points(path: &Vec<&str>) -> HashMap<(i32, i32), usize> {
let mut directions = HashMap::new();
directions.insert('U', (0, 1));
directions.insert('D', (0, -1));
directions.insert('L', (-1, 0));
directions.insert('R', (1, 0));
let directions = vec![('U', (0, 1)), ('D', (0, -1)), ('L', (-1, 0)), ('R', (1, 0))]
.into_iter()
.collect::<HashMap<_, _>>();
path.iter()
.map(|it| {
let direction = it.chars().next().unwrap();