Skip to content

Commit

Permalink
2024-18 Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
jurisk committed Dec 18, 2024
1 parent 10e3675 commit 61ce4b1
Show file tree
Hide file tree
Showing 5 changed files with 3,590 additions and 0 deletions.
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

| Year-Day | Task | Scala | Rust | Others |
|----------|:-------------------------------------------------------------------------------|:-----------------------------------------------------------------------:|:----------------------------------------------:|:----------------------------------------------------------------------:|
| 2024-18 | [RAM Run](https://adventofcode.com/2024/day/18) | [Scala](scala2/src/main/scala/jurisk/adventofcode/y2024/Advent18.scala) | [Rust](rust/y2024/src/bin/solution_2024_18.rs) | |
| 2024-17 | [Chronospatial Computer](https://adventofcode.com/2024/day/17) | [Scala](scala2/src/main/scala/jurisk/adventofcode/y2024/Advent17.scala) | [Rust](rust/y2024/src/bin/solution_2024_17.rs) | |
| 2024-16 | [Reindeer Maze](https://adventofcode.com/2024/day/16) | [Scala](scala2/src/main/scala/jurisk/adventofcode/y2024/Advent16.scala) | [Rust](rust/y2024/src/bin/solution_2024_16.rs) | |
| 2024-15 | [Warehouse Woes](https://adventofcode.com/2024/day/15) | [Scala](scala2/src/main/scala/jurisk/adventofcode/y2024/Advent15.scala) | [Rust](rust/y2024/src/bin/solution_2024_15.rs) | |
Expand Down
7 changes: 7 additions & 0 deletions rust/common/src/area2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ impl<T: Copy + Ord + Step> Area2D<T> {
}
}

pub fn contains(&self, point: Coords2D<T>) -> bool {
point.x >= self.min.x
&& point.x <= self.max.x
&& point.y >= self.min.y
&& point.y <= self.max.y
}

pub fn points(self) -> Vec<Coords2D<T>> {
(self.min.x ..= self.max.x)
.collect::<Vec<_>>()
Expand Down
25 changes: 25 additions & 0 deletions rust/y2024/resources/18-test-00.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
5,4
4,2
4,5
3,0
2,1
6,3
2,4
1,5
0,6
3,3
2,6
5,1
1,2
5,5
2,5
6,5
1,4
0,4
6,4
1,1
6,1
1,0
0,5
1,6
2,0
Loading

0 comments on commit 61ce4b1

Please sign in to comment.