-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: removed coord implementation in favor of Vec2
- Loading branch information
Showing
8 changed files
with
46 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { split } from '@alexaegis/advent-of-code-lib'; | ||
import { Vector } from './model/vector.class.js'; | ||
import { MotionVector } from './model/motion-vector.class.js'; | ||
|
||
export const interpreter = (input: string): Vector[] => | ||
split(input).map((line) => Vector.parse(line)); | ||
export const interpreter = (input: string): MotionVector[] => | ||
split(input).map((line) => MotionVector.parse(line)); |
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
solutions/typescript/2018/10/src/model/motion-vector.class.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Vec2, type Vec2String } from '@alexaegis/advent-of-code-lib'; | ||
import { type } from 'arktype'; | ||
|
||
export class MotionVector { | ||
static inputType = type(['string', 'string', 'string', 'string', 'string']); | ||
public constructor( | ||
public position: Vec2, | ||
public velocity: Vec2, | ||
) {} | ||
|
||
static parse(input: string): MotionVector { | ||
const split = MotionVector.inputType.assert(input.split(/[<>]/)); | ||
return new MotionVector(new Vec2(split[1] as Vec2String), new Vec2(split[3] as Vec2String)); | ||
} | ||
|
||
public move(): Vec2 { | ||
return this.position.addMut(this.velocity); | ||
} | ||
|
||
public toString(): string { | ||
return `<${this.position.toString()}> , <${this.velocity.toString()}>`; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters