{"size": 1709, "ext": "js", "max_stars_repo_path": "aoc_2021/test/day17.test.js", "max_stars_repo_name": "ambertests/adventofcode", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "aoc_2021/test/day17.test.js", "max_issues_repo_name": "ambertests/adventofcode", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "aoc_2021/test/day17.test.js", "max_forks_repo_name": "ambertests/adventofcode", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.8653846154, "max_line_length": 64, "alphanum_fraction": 0.5441778818}
const {
    solution,
    makeTarget,
    launchProbe,
    analyzeLaunches,
} = require("../days/day17");
const { expect } = require("chai");

const testData = "target area: x=20..30, y=-10..-5";
describe("Day 17 solve", function () {
    it("parses string correctly", function () {
        const target = makeTarget(testData);
        expect(target.min_x).to.equal(20);
        expect(target.max_x).to.equal(30);
        expect(target.min_y).to.equal(-10);
        expect(target.max_y).to.equal(-5);
    });
    describe("predicts target hits correctly", function () {
        const target = makeTarget(testData);
        it("example 1", function () {
            expect(launchProbe(target, 7, 2).hit).to.be.true;
        });
        it("example 2", function () {
            expect(launchProbe(target, 6, 3).hit).to.be.true;
        });
        it("example 3", function () {
            expect(launchProbe(target, 9, 0).hit).to.be.true;
        });
        it("example 4", function () {
            expect(launchProbe(target, 17, -4).hit).to.be.false;
        });
    });
    describe("test data", function () {
        const target = makeTarget(testData);
        const result = analyzeLaunches(target);
        it("gets max possible height", function () {
            expect(result.maxHeight).to.equal(45);
        });
        it("gets success count", function () {
            expect(result.successCount).to.equal(112);
        });
    });
    describe("real data", function () {
        it("works for part 1", function () {
            expect(solution.pt1).to.equal(5565);
        });
        it("works for part 2", function () {
            expect(solution.pt2).to.equal(2118);
        });
    });
});
