Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
nuxeh committed Dec 5, 2021
1 parent 35b213f commit b593d4b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion 05/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use aocf::Aoc;
use std::collections::HashMap;

#[derive(Debug)]
#[derive(Debug, PartialEq, Eq, Hash)]
struct Point {
x: i32,
y: i32,
Expand Down Expand Up @@ -67,6 +67,8 @@ fn main() {
}

fn run(i: &str) {
let points: HashMap<Point, usize> = HashMap::new();

let lines: Vec<Line> = i
.lines()
.map(|l| Line::from_str(l))
Expand All @@ -77,5 +79,14 @@ fn run(i: &str) {
for line in lines {
println!("{:?}", line);
println!("{:?}", line.cast());

line
.cast()
.for_each(|point| {
match points.get(point) {
Some(count) => points.insert(*point, count+1),
None => points.insert(*point, 1),
};
});
}
}

0 comments on commit b593d4b

Please sign in to comment.