Skip to content

Commit

Permalink
fix ws
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-the-Bomb committed Dec 19, 2023
1 parent 77cdd44 commit 04dc76b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions aoc-py/solutions/day18.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _parse_p1(self, line: str) -> Entry:
'R': (1, 0),
}.get(direction, (0, 0))
)

def _parse_p2(self, line: str) -> Entry:
"""Parses each line from Part 2:
- ignores the provided direction and distance
Expand Down Expand Up @@ -74,7 +74,7 @@ def _shoelace(self, points: Points) -> int:
this value is not of use to us at all directly as it works for cartesian polygons
(it has no meaning in this application)
but it is only useful to input into `Pick's Theorem` as `A`
<https://en.wikipedia.org/wiki/Shoelace_formula>
"""
return abs(
Expand Down Expand Up @@ -123,7 +123,7 @@ def _get_area(self, data: Iterator[Entry]) -> int:
# A = what we get from applying the `shoelace formula``
# b = `perimeter` (which is the same as # of interior boundary lattice points in this case)
# i + b = internal lattice + boundary lattice = the desired output for us
#
#
return self._shoelace(points) + perimeter // 2 + 1

def part_one(self, inp: str) -> int:
Expand Down
12 changes: 6 additions & 6 deletions src/bin/day18.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Day18 {
T: AsRef<[(i64, i64)]>
{
let points = points.as_ref();

(points
.iter()
.zip(
Expand All @@ -33,14 +33,14 @@ impl Day18 {
}

/// Uses shoelace formula + Pick's theorem to find the total area
///
///
/// `A + b/2 + 1 = i + b`
/// where A = shoelace result
/// b = perimeter
/// i + b = desired result
///
///
/// # Panics
///
///
/// If the vector of points is empty
fn get_area<T>(data: T) -> i64
where
Expand All @@ -64,7 +64,7 @@ impl Day18 {
}

/// # Panics
///
///
/// If failed to parse input numbers
pub fn part_one<T: Display>(&self, inp: T) -> i64 {
let inp = inp.to_string();
Expand Down Expand Up @@ -92,7 +92,7 @@ impl Day18 {
}

/// # Panics
///
///
/// If failed to parse input numbers
pub fn part_two<T: Display>(&self, inp: T) -> i64 {
let inp = inp.to_string();
Expand Down

0 comments on commit 04dc76b

Please sign in to comment.