[ya-day1] 6 1 A yandex solution
This commit is contained in:
@@ -2,35 +2,35 @@ import { describe, it, expect } from "vitest";
|
||||
import { toGetClosestPoint } from "./toGetClosestPoint.ts";
|
||||
|
||||
describe("toGetClosestPoint", () => {
|
||||
it("toGetClosestPoint equale NW", () => {
|
||||
it("-1, -2, 5, 3, -4, 6 equale NW", () => {
|
||||
expect(toGetClosestPoint(-1, -2, 5, 3, -4, 6)).toBe("NW");
|
||||
});
|
||||
|
||||
it("toGetClosestPoint equale N", () => {
|
||||
it("-1, -2, 5, 3, 4, 5 equale N", () => {
|
||||
expect(toGetClosestPoint(-1, -2, 5, 3, 4, 5)).toBe("N");
|
||||
});
|
||||
|
||||
it("toGetClosestPoint equale NE", () => {
|
||||
it("-1, -2, 5, 3, 9, 3 equale NE", () => {
|
||||
expect(toGetClosestPoint(-1, -2, 5, 3, 9, 3)).toBe("NE");
|
||||
});
|
||||
|
||||
it("toGetClosestPoint equale E", () => {
|
||||
it("-1, -2, 5, 3, 7, 0 equale E", () => {
|
||||
expect(toGetClosestPoint(-1, -2, 5, 3, 7, 0)).toBe("E");
|
||||
});
|
||||
|
||||
it("toGetClosestPoint equale SE", () => {
|
||||
it("-1, -2, 5, 3, 8, -4 equale SE", () => {
|
||||
expect(toGetClosestPoint(-1, -2, 5, 3, 8, -4)).toBe("SE");
|
||||
});
|
||||
|
||||
it("toGetClosestPoint equale S", () => {
|
||||
it("-1, -2, 5, 3, 2, -4 equale S", () => {
|
||||
expect(toGetClosestPoint(-1, -2, 5, 3, 2, -4)).toBe("S");
|
||||
});
|
||||
|
||||
it("toGetClosestPoint equale SW", () => {
|
||||
it("-1, -2, 5, 3, -5, -2 equale SW", () => {
|
||||
expect(toGetClosestPoint(-1, -2, 5, 3, -5, -2)).toBe("SW");
|
||||
});
|
||||
|
||||
it("toGetClosestPoint equale W", () => {
|
||||
it("-1, -2, 5, 3, -5, 2 equale W", () => {
|
||||
expect(toGetClosestPoint(-1, -2, 5, 3, -5, 2)).toBe("W");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,3 +22,20 @@ export function toGetClosestPoint(
|
||||
|
||||
return direction;
|
||||
}
|
||||
// export function toGetClosestPoint(
|
||||
// x1: number,
|
||||
// y1: number,
|
||||
// x2: number,
|
||||
// y2: number,
|
||||
// sx: number,
|
||||
// sy: number,
|
||||
// ) {
|
||||
// let direction: Direction = "" as Direction;
|
||||
|
||||
// if (sy > y2) direction += "N"
|
||||
// if (sy < y1) direction += "S";
|
||||
// if (sx < x1) direction += "W"
|
||||
// if (sx > x2) direction += "E"
|
||||
|
||||
// return direction;
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user