Skip to content

Commit 4cab7a0

Browse files
committed
moving to let
1 parent 486d7ff commit 4cab7a0

File tree

487 files changed

+2002
-2015
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

487 files changed

+2002
-2015
lines changed

src/2015/day01.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day01.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day01 2015", () => {
77
describe("part1", () => {

src/2015/day02.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day02.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day02 2015", () => {
77
describe("part1", () => {

src/2015/day03.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function step(x, y) {
22
return pos => ({ x: pos.x + x, y: pos.y + y });
33
}
44

5-
const steps = {
5+
let steps = {
66
"<": step(-1, 0),
77
">": step(1, 0),
88
"^": step(0, -1),
@@ -16,7 +16,7 @@ function parse(input) {
1616
export function part1(input) {
1717
return parse(input).reduce(
1818
(state, next) => {
19-
const pos = (state.pos = next(state.pos));
19+
let pos = (state.pos = next(state.pos));
2020
state.visited.add(`${pos.x}-${pos.y}`);
2121
return state;
2222
},
@@ -27,8 +27,8 @@ export function part1(input) {
2727
export function part2(input) {
2828
return parse(input).reduce(
2929
(state, next, index) => {
30-
const turn = index % 2 === 0 ? "santa" : "robot";
31-
const pos = (state.pos[turn] = next(state.pos[turn]));
30+
let turn = index % 2 === 0 ? "santa" : "robot";
31+
let pos = (state.pos[turn] = next(state.pos[turn]));
3232
state.visited.add(`${pos.x}-${pos.y}`);
3333
return state;
3434
},

src/2015/day03.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day03.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day03 2015", () => {
77
describe("part1", () => {

src/2015/day04.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day04.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day04 2015", () => {
77
describe("part1", () => {

src/2015/day05.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day05.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day05 2015", () => {
77
describe("part1", () => {

src/2015/day06.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day06.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day06 2015", () => {
77
describe("part1", () => {

src/2015/day07.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const ops = {
1+
let ops = {
22
AND: (p1, p2) => (2 ** 16 + (p1 & p2)) % 2 ** 16,
33
OR: (p1, p2) => (2 ** 16 + (p1 | p2)) % 2 ** 16,
44
NOT: (p1, p2) => (2 ** 16 + ~p2) % 2 ** 16,
@@ -24,7 +24,7 @@ function makeCircuit(input) {
2424
}))
2525
.reduce((circuit, gate) => {
2626
circuit[gate.result] = () => {
27-
const memo = gate.op(gate.p1(circuit), gate.p2(circuit));
27+
let memo = gate.op(gate.p1(circuit), gate.p2(circuit));
2828
circuit[gate.result] = () => memo;
2929
return memo;
3030
};

src/2015/day07.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day07.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day07 2015", () => {
77
describe("part1", () => {

src/2015/day08.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day08.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day08 2015", () => {
77
describe("part1", () => {

src/2015/day09.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function shortest(graph, curr, visited) {
2-
const paths = Object.keys(graph[curr])
2+
let paths = Object.keys(graph[curr])
33
.filter(node => visited.indexOf(node) === -1)
44
.map(
55
node => graph[curr][node] + shortest(graph, node, visited.concat(curr)),
@@ -8,7 +8,7 @@ function shortest(graph, curr, visited) {
88
}
99

1010
function longest(graph, curr, visited) {
11-
const paths = Object.keys(graph[curr])
11+
let paths = Object.keys(graph[curr])
1212
.filter(node => visited.indexOf(node) === -1)
1313
.map(
1414
node => graph[curr][node] + longest(graph, node, visited.concat(curr)),
@@ -17,7 +17,7 @@ function longest(graph, curr, visited) {
1717
}
1818

1919
function parse(input) {
20-
const graph = input
20+
let graph = input
2121
.split("\n")
2222
.map(x => x.match(/^(.*) to (.*) = (\d+)$/))
2323
.map(([, p1, p2, d]) => ({ p1, p2, d: +d }))

src/2015/day09.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day09.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day09 2015", () => {
77
describe("part1", () => {

src/2015/day10.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day10.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day10 2015", () => {
77
describe("part1", () => {

src/2015/day11.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const abc = "abcdefghijklmnopqrstuvwxyz";
2-
const subStrings = abc
1+
let abc = "abcdefghijklmnopqrstuvwxyz";
2+
let subStrings = abc
33
.split("")
44
.map((x, i) => abc.substr(i, 3))
55
.filter(x => x.length === 3);

src/2015/day11.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day11.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day11 2015", () => {
77
describe("part1", () => {

src/2015/day12.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function deepSum(obj, ignore) {
22
if (Array.isArray(obj)) {
33
return obj.reduce((sum, x) => sum + deepSum(x, ignore), 0);
44
} else if (typeof obj === "object") {
5-
const values = Object.keys(obj).map(x => obj[x]);
5+
let values = Object.keys(obj).map(x => obj[x]);
66
return ignore && values.indexOf(ignore) > -1 ? 0 : deepSum(values, ignore);
77
} else {
88
return typeof obj === "number" ? obj : 0;

src/2015/day12.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day12.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day12 2015", () => {
77
describe("part1", () => {

src/2015/day13.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function longest(graph, curr, visited) {
2-
const paths = Object.keys(graph[curr])
2+
let paths = Object.keys(graph[curr])
33
.filter(node => visited.indexOf(node) === -1)
44
.map(
55
node => graph[curr][node] + longest(graph, node, visited.concat(curr)),
@@ -8,15 +8,15 @@ function longest(graph, curr, visited) {
88
}
99

1010
function parse(input) {
11-
const signs = { gain: +1, lose: -1 };
12-
const graph = input
11+
let signs = { gain: +1, lose: -1 };
12+
let graph = input
1313
.split("\n")
1414
.map(x =>
1515
x.match(/^(.*) would (gain|lose) (\d+) happiness .* next to (.*)\.$/),
1616
)
1717
.map(x => ({ p1: x[1], p2: x[4], d: signs[x[2]] * +x[3] }))
1818
.reduce((graph, edge) => {
19-
const prev = (graph[edge.p1] && graph[edge.p1][edge.p2]) || 0;
19+
let prev = (graph[edge.p1] && graph[edge.p1][edge.p2]) || 0;
2020
graph[edge.p1] = { ...graph[edge.p1], [edge.p2]: edge.d + prev };
2121
graph[edge.p2] = { ...graph[edge.p2], [edge.p1]: edge.d + prev };
2222
return graph;
@@ -29,11 +29,11 @@ function parse(input) {
2929
}
3030

3131
export function part1(input) {
32-
const graph = parse(input);
32+
let graph = parse(input);
3333
return longest(graph, Object.keys(graph).shift(), []);
3434
}
3535

3636
export function part2(input) {
37-
const graph = parse(input);
37+
let graph = parse(input);
3838
return longest(graph, "$$me", []);
3939
}

src/2015/day13.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day13.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day13 2015", () => {
77
describe("part1", () => {

src/2015/day14.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ function parse(input) {
1414
function run(race, seconds) {
1515
for (let i = 0; i < seconds; i++) {
1616
race = race.map(x => {
17-
const ran = i % (x.fly + x.rest) < x.fly;
17+
let ran = i % (x.fly + x.rest) < x.fly;
1818
x.distance += ran ? x.speed : 0;
1919
return x;
2020
});
2121

22-
const lead = race.reduce((prev, x) => Math.max(prev, x.distance), 0);
22+
let lead = race.reduce((prev, x) => Math.max(prev, x.distance), 0);
2323
race.filter(x => x.distance === lead).forEach(x => x.points++);
2424
}
2525
return race;
2626
}
2727

2828
export function part1(input, seconds = 2503) {
29-
const race = run(parse(input), seconds);
29+
let race = run(parse(input), seconds);
3030
return race.reduce((prev, x) => Math.max(prev, x.distance), 0);
3131
}
3232

3333
export function part2(input, seconds = 2503) {
34-
const race = run(parse(input), seconds);
34+
let race = run(parse(input), seconds);
3535
return race.reduce((prev, x) => Math.max(prev, x.points), 0);
3636
}

src/2015/day14.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day14.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day14 2015", () => {
77
describe("part1", () => {

src/2015/day15.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export function day(input) {
22
function add(digits, param, i) {
33
i = i || 0;
44
if (i < digits.length) {
5-
const sum = digits[i] + param;
6-
const pass = Math.floor(sum / 101);
5+
let sum = digits[i] + param;
6+
let pass = Math.floor(sum / 101);
77
digits[i] = sum % 101;
88
return pass ? add(digits, pass, i + 1) : digits;
99
}
@@ -22,24 +22,24 @@ export function day(input) {
2222
}, {});
2323
}
2424

25-
const ingredients = input
25+
let ingredients = input
2626
.split("\n")
2727
.map(x => x.match(/^.*: (.*)$/))
2828
.map(([, s]) => parseMap(s, ", ", " "));
2929

3030
let part1 = 0,
3131
part2 = 0;
32-
const spoons = new Array(ingredients.length).fill(0);
32+
let spoons = new Array(ingredients.length).fill(0);
3333
while (add(spoons, 100)) {
3434
if (spoons.reduce((prev, x) => prev + x) === 100) {
35-
const amounts = ingredients.map((x, index) =>
35+
let amounts = ingredients.map((x, index) =>
3636
objMap(x, property => property * spoons[index]),
3737
);
38-
const sum = amounts.reduce((prev, x) =>
38+
let sum = amounts.reduce((prev, x) =>
3939
objMap(x, (value, key) => prev[key] + value),
4040
);
41-
const properties = Object.keys(sum).filter(x => x !== "calories");
42-
const result = properties
41+
let properties = Object.keys(sum).filter(x => x !== "calories");
42+
let result = properties
4343
.map(x => Math.max(0, sum[x]))
4444
.reduce((prev, x) => prev * x);
4545

src/2015/day15.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { day } from "./day15.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day15 2015", () => {
77
test("it should work for example", () => {
8-
const { part1, part2 } = day(
8+
let { part1, part2 } = day(
99
[
1010
"Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8",
1111
"Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3",
@@ -16,7 +16,7 @@ describe("day15 2015", () => {
1616
});
1717

1818
test("it should work for input", () => {
19-
const { part1, part2 } = day(input);
19+
let { part1, part2 } = day(input);
2020
expect(part1).toEqual(13882464);
2121
expect(part2).toEqual(11171160);
2222
});

src/2015/day16.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const expect1 = {
1+
let expect1 = {
22
id: () => true,
33
children: 3,
44
cats: 7,
@@ -12,7 +12,7 @@ const expect1 = {
1212
perfumes: 1,
1313
};
1414

15-
const expect2 = {
15+
let expect2 = {
1616
...expect1,
1717
cats: x => x > expect1.cats,
1818
trees: x => x > expect1.trees,

src/2015/day16.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { part1, part2 } from "./day16.js";
22
import readInput from "../utils/read-input.js";
33

4-
const input = readInput(import.meta.url);
4+
let input = readInput(import.meta.url);
55

66
describe("day16 2015", () => {
77
describe("part1", () => {

src/2015/day17.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export function day(input, fill = 150) {
2-
const boxes = input.split("\n").map(Number);
3-
const result = new Array(boxes.length).fill(0);
4-
const pad = result.join("");
2+
let boxes = input.split("\n").map(Number);
3+
let result = new Array(boxes.length).fill(0);
4+
let pad = result.join("");
55

66
for (let i = 2 ** boxes.length - 1; i > 0; i--) {
7-
const select = (pad + i.toString(2))
7+
let select = (pad + i.toString(2))
88
.slice(-boxes.length)
99
.split("")
1010
.map(Number);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy