Skip to content

Commit bc708e8

Browse files
committed
Tidy tests
1 parent 5710c8a commit bc708e8

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

day-19-go-with-the-flow/assembly.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ function executeProgram(input, register0Value = 0) {
9090
while(ip >= 0 && ip < inputLines.length) {
9191
let instruction = inputLines[ip].split(' ');
9292
//OPTIMISER
93-
if (ip == 2 && registers[1] != 0) {
94-
if ((registers[4] % registers[1])==0){
95-
registers[0] += registers[1];
93+
if (register0Value != 0) { //only optimise part 2
94+
if (ip == 2 && registers[1] != 0) {
95+
if ((registers[4] % registers[1])==0){
96+
registers[0] += registers[1];
97+
}
98+
registers[3] = registers[4];
99+
registers[ipBind] = 12;
100+
ip=registers[ipBind];
101+
continue;
96102
}
97-
registers[3] = registers[4];
98-
registers[ipBind] = 12;
99-
ip=registers[ipBind];
100-
continue;
101103
}
102104

103105
opcodes[instruction[0]].run(+instruction[1],+instruction[2],+instruction[3], registers);

day-23-experimental-emergency-teleportation/nanobots.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ class Nanobot {
8181

8282
function calculateNanobotsInRange(input) {
8383
let nanobots = parseCoordinates(input).sort((a, b) => b.range - a.range);
84-
nanobots.forEach(bot => console.log('{pos:['+bot.point.x+','+bot.point.y+',' + bot.point.z+'], r:'+bot.range+'},'));
85-
8684
let biggestRange = nanobots[0];
8785
return nanobots.filter(bot => bot.calculateManhattenDistance(biggestRange) <= biggestRange.range).length;
8886
}

day-23-experimental-emergency-teleportation/test.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ const nanobots = require('./nanobots');
88
const BoundingBox = nanobots.BoundingBox;
99
const Point = nanobots.Point;
1010

11-
const solution = require('./solution');
12-
13-
describe('Day 23: Experimental Emergency Teleportation', () => {
11+
describe.only('Day 23: Experimental Emergency Teleportation', () => {
1412

1513
describe('Part One', () => {
1614
it('should calculate range of nanobots', () => {
@@ -31,16 +29,6 @@ describe('Day 23: Experimental Emergency Teleportation', () => {
3129
const input = fs.readFileSync('day-23-experimental-emergency-teleportation/input.txt').toString();
3230
expect(nanobots.calculateNanobotsInRange(input)).to.equal(619);
3331
});
34-
35-
it('Input file should return', () => {
36-
const input = fs.readFileSync('day-23-experimental-emergency-teleportation/input.txt').toString();
37-
solution.run(input);
38-
});
39-
40-
it('Input file should return', () => {
41-
const input = fs.readFileSync('day-23-experimental-emergency-teleportation/input.txt').toString();
42-
expect(nanobots.getNanobotsForPoint(input, 20407349, 13636438, 35377809)).to.equal(619);
43-
});
4432
});
4533

4634
describe('Part Two', () => {
@@ -99,15 +87,15 @@ describe('Day 23: Experimental Emergency Teleportation', () => {
9987
pos=<14,14,14>, r=6
10088
pos=<50,50,50>, r=200
10189
pos=<10,10,10>, r=5`;
102-
expect(nanobots.calculateBestCoordinates(coords)).to.equal(36);
90+
expect(nanobots.redditAttempt(coords)).to.equal(36);
10391
});
10492

10593
it('Input file should return', () => {
10694
const input = fs.readFileSync('day-23-experimental-emergency-teleportation/input.txt').toString();
10795
expect(nanobots.redditAttempt(input)).to.equal(71631000); //too low
10896
});
10997

110-
it('Input file should return', () => {
98+
it.skip('Input file should return', () => {
11199
const input = fs.readFileSync('day-23-experimental-emergency-teleportation/input.txt').toString();
112100
expect(nanobots.calculateBestCoordinatesWithAnswer(input)).to.equal(71631000); //too low
113101
}).timeout(1000000);

0 commit comments

Comments
 (0)