cleanup day 3

This commit is contained in:
Gleb Koval 2023-12-05 01:41:44 +00:00
parent 13b2e3f72e
commit a007a5a19d
Signed by: cyclane
GPG Key ID: 15E168A8B332382C
1 changed files with 9 additions and 9 deletions

View File

@ -26,15 +26,6 @@ function toSubComponents(l: string) {
type Component = [number, number, string]; type Component = [number, number, string];
function isPartNumber(
components: Component[],
component: Component,
) {
return Boolean(
components.find((c) => isAdjacent(component, c) && c[2] !== "."),
);
}
/** /**
* Checks whether two components are adjacent * Checks whether two components are adjacent
* @param c1 First component. * @param c1 First component.
@ -51,6 +42,15 @@ function isAdjacent([y1, x1, s1]: Component, [y2, x2, s2]: Component) {
) || (y1 === y2) && (x2e === x1 - 1 || x2 === x1e + 1); ) || (y1 === y2) && (x2e === x1 - 1 || x2 === x1e + 1);
} }
function isPartNumber(
components: Component[],
component: Component,
) {
return Boolean(
components.find((c) => isAdjacent(component, c) && c[2] !== "."),
);
}
function gearRatio( function gearRatio(
components: Component[], components: Component[],
component: Component, component: Component,