Skip to content

Commit 6bf1bcd

Browse files
committed
Make room for 2017.
1 parent 4b55f4e commit 6bf1bcd

Some content is hidden

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

45 files changed

+91
-74
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# EditorConfig: http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 2
12+
13+
[package.json]
14+
indent_style = space
15+
indent_size = 2

01/test.js

-24
This file was deleted.
File renamed without changes.

01/input renamed to 2015/01/input

File renamed without changes.

01/silver.js renamed to 2015/01/silver.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Bacon from 'baconjs'
2-
import sum from '../lib/sum'
2+
import sum from '../../lib/sum'
33

44
export default input$ => input$
55
.flatMap(input => Bacon.fromArray(input.split('')))

2015/01/test.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* eslint-env mocha */
2+
3+
import describeTestCases from '../../lib/describe-test-cases'
4+
5+
import silver from './silver'
6+
import gold from './gold'
7+
8+
describe('2015-12-01', () => {
9+
describeTestCases('silver', silver, [
10+
['(())', 0],
11+
['()()', 0],
12+
['(((', 3],
13+
['(()(()(', 3],
14+
['))(((((', 3],
15+
['())', -1],
16+
['))(', -1],
17+
[')))', -3],
18+
[')())())', -3]
19+
])
20+
describeTestCases('gold', gold, [
21+
[')', 1],
22+
['()())', 5]
23+
])
24+
})
File renamed without changes.

02/gold.js renamed to 2015/02/gold.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Bacon from 'baconjs'
2-
import sum from '../lib/sum'
2+
import sum from '../../lib/sum'
33
import lengthOfRibbon from './length-of-ribbon'
4-
import numericCompare from '../lib/numeric-compare'
4+
import numericCompare from '../../lib/numeric-compare'
55

66
const OK_LINE = /\d+x\d+x\d+/
77

02/input renamed to 2015/02/input

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

02/silver.js renamed to 2015/02/silver.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Bacon from 'baconjs'
2-
import sum from '../lib/sum'
2+
import sum from '../../lib/sum'
33
import areaOfBox from './area-of-box'
4-
import numericCompare from '../lib/numeric-compare'
4+
import numericCompare from '../../lib/numeric-compare'
55

66
const OK_LINE = /\d+x\d+x\d+/
77

02/test.js renamed to 2015/02/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-env mocha */
2-
import describeTestCases from '../lib/describe-test-cases'
2+
import describeTestCases from '../../lib/describe-test-cases'
33

44
import silver from './silver'
55
import gold from './gold'
66

7-
describe('02', () => {
7+
describe('2015-12-02', () => {
88
describeTestCases('silver', silver, [
99
['2x3x4', 58],
1010
['1x1x10', 43]
File renamed without changes.

03/input renamed to 2015/03/input

File renamed without changes.
File renamed without changes.

03/test.js renamed to 2015/03/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-env mocha */
2-
import describeTestCases from '../lib/describe-test-cases'
2+
import describeTestCases from '../../lib/describe-test-cases'
33

44
import silver from './silver'
55
import gold from './gold'
66

7-
describe('03', () => {
7+
describe('2015-12-03', () => {
88
describeTestCases('silver', silver, [
99
['>', 2],
1010
['^>v<', 4],
File renamed without changes.
File renamed without changes.
File renamed without changes.

04/input renamed to 2015/04/input

File renamed without changes.
File renamed without changes.

04/test.js renamed to 2015/04/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* eslint-env mocha */
22
import fs from 'fs'
33
import path from 'path'
4-
import describeTestCases from '../lib/describe-test-cases'
4+
import describeTestCases from '../../lib/describe-test-cases'
55

66
import silver from './silver'
77
import gold from './gold'
88

9-
describe.skip('04 - skipped because quite slow', () => {
9+
describe.skip('2015-12-04 - skipped because quite slow', () => {
1010
describeTestCases('silver', silver, [
1111
['abcdef', 609043],
1212
['pqrstuv', 1048970],

05/gold.js renamed to 2015/05/gold.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Bacon from 'baconjs'
22

3-
import count from '../lib/count'
3+
import count from '../../lib/count'
44

55
export default input$ => input$
66
.flatMap(input => Bacon.fromArray(input.split('\n')))

05/input renamed to 2015/05/input

File renamed without changes.

05/silver.js renamed to 2015/05/silver.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Bacon from 'baconjs'
22

3-
import count from '../lib/count'
3+
import count from '../../lib/count'
44

55
export default input$ => input$
66
.flatMap(input => Bacon.fromArray(input.split('\n')))

05/test.js renamed to 2015/05/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* eslint-env mocha */
22
import fs from 'fs'
33
import path from 'path'
4-
import describeTestCases from '../lib/describe-test-cases'
4+
import describeTestCases from '../../lib/describe-test-cases'
55

66
import silver from './silver'
77
import gold from './gold'
88

9-
describe('05', () => {
9+
describe('2015-12-05', () => {
1010
describeTestCases('silver', silver, [
1111
['ugknbfddgicrmopn', 1],
1212
['aaa', 1],

06/algorithm.js renamed to 2015/06/algorithm.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Bacon from 'baconjs'
22
import _ from 'lodash'
3-
import numericCompare from '../lib/numeric-compare'
3+
import numericCompare from '../../lib/numeric-compare'
44

55
const operateOnLights = (lights, [operation, x1, y1, x2, y2]) => {
66
const [fromX, toX] = [x1, x2].sort(numericCompare)
File renamed without changes.

06/input renamed to 2015/06/input

File renamed without changes.
File renamed without changes.

06/test.js renamed to 2015/06/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* eslint-env mocha */
22
import fs from 'fs'
33
import path from 'path'
4-
import describeTestCases from '../lib/describe-test-cases'
4+
import describeTestCases from '../../lib/describe-test-cases'
55

66
import silver from './silver'
77
import gold from './gold'
88

9-
describe.skip('06 - skipped because quite slow', () => {
9+
describe.skip('2015-12-06 - skipped because quite slow', () => {
1010
describeTestCases('silver', silver, [
1111
['turn on 0,0 through 999,999', 1000000],
1212
['toggle 0,0 through 999,0', 1000],
File renamed without changes.

07/input renamed to 2015/07/input

File renamed without changes.
File renamed without changes.
File renamed without changes.

07/test.js renamed to 2015/07/test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint-env mocha */
22
import fs from 'fs'
33
import path from 'path'
4-
import describeTestCases from '../lib/describe-test-cases'
5-
import describeSimpleTestCases from '../lib/describe-simple-test-cases'
4+
import describeTestCases from '../../lib/describe-test-cases'
5+
import describeSimpleTestCases from '../../lib/describe-simple-test-cases'
66

77
import jsExpression from './js-expression'
88
import silver from './silver'
99
import gold from './gold'
1010

11-
describe('07', () => {
11+
describe('2015-12-07', () => {
1212
describeSimpleTestCases('js-expression', jsExpression, [
1313
['123', '123'],
1414
['x', '_x()'],

08/gold.js renamed to 2015/08/gold.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Bacon from 'baconjs'
22
import _ from 'lodash'
33

4-
import sum from '../lib/sum'
4+
import sum from '../../lib/sum'
55

66
export default input$ => input$
77
.flatMap(input => Bacon.fromArray(input.split('\n')))

08/input renamed to 2015/08/input

File renamed without changes.

08/silver.js renamed to 2015/08/silver.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Bacon from 'baconjs'
22

3-
import sum from '../lib/sum'
3+
import sum from '../../lib/sum'
44

55
export default input$ => input$
66
.flatMap(input => Bacon.fromArray(input.split('\n')))

08/test.js renamed to 2015/08/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* eslint-env mocha */
22
import fs from 'fs'
33
import path from 'path'
4-
import describeTestCases from '../lib/describe-test-cases'
4+
import describeTestCases from '../../lib/describe-test-cases'
55

66
import silver from './silver'
77
import gold from './gold'
88

9-
describe('08', () => {
9+
describe('2015-12-08', () => {
1010
describeTestCases('silver', silver, [
1111
['""', 2 - 0],
1212
['"abc"', 5 - 3],

README.md

+2-2

index.js

+24-22
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,33 @@ import safeRequire from './lib/safe-require'
88
import formatWithTwoDigits from './lib/format-with-two-digits'
99
import numericCompareProperty from './lib/numeric-compare-property'
1010

11+
const year = process.argv[2]
12+
1113
Bacon.constant(process)
12-
.map(process => process.argv.splice(2))
13-
.flatMap(args => Bacon.fromArray(args))
14-
.map(Number)
15-
.map(formatWithTwoDigits)
16-
.map(number => ({
17-
number,
18-
silverMod: safeRequire(`${__dirname}/${number}/silver`),
19-
goldMod: safeRequire(`${__dirname}/${number}/gold`),
20-
inputFilename: path.join(__dirname, number, 'input')
21-
}))
22-
.map(({number, silverMod, goldMod, inputFilename}) => ({
23-
number,
24-
silverFn: silverMod && silverMod.default,
25-
goldFn: goldMod && goldMod.default,
26-
input$: Bacon.fromNodeCallback(readFile, inputFilename, 'utf-8')
27-
}))
28-
.flatMap(
14+
.map(process => process.argv.splice(3))
15+
.flatMap(args => Bacon.fromArray(args))
16+
.map(Number)
17+
.map(formatWithTwoDigits)
18+
.map(number => ({
19+
number,
20+
silverMod: safeRequire(`${__dirname}/${year}/${number}/silver`),
21+
goldMod: safeRequire(`${__dirname}/${year}/${number}/gold`),
22+
inputFilename: path.join(__dirname, year, number, 'input')
23+
}))
24+
.map(({number, silverMod, goldMod, inputFilename}) => ({
25+
number,
26+
silverFn: silverMod && silverMod.default,
27+
goldFn: goldMod && goldMod.default,
28+
input$: Bacon.fromNodeCallback(readFile, inputFilename, 'utf-8')
29+
}))
30+
.flatMap(
2931
({number, silverFn, goldFn, input$}) => Bacon.zipAsArray([
3032
Bacon.once(number),
3133
(silverFn && silverFn(input$)) || Bacon.once(null),
3234
(goldFn && goldFn(input$)) || Bacon.once(null)
3335
])
34-
)
35-
.map(([number, silver, gold]) => ({number, silver, gold}))
36-
.reduce([], (results, result) => results.concat(result))
37-
.map(results => results.sort(numericCompareProperty('number')))
38-
.onValue(console.log)
36+
)
37+
.map(([number, silver, gold]) => ({year, number, silver, gold}))
38+
.reduce([], (results, result) => results.concat(result))
39+
.map(results => results.sort(numericCompareProperty('number')))
40+
.onValue(console.log)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Me doing the adventofcode.com exercises.",
55
"scripts": {
66
"start": "node -r @std/esm .",
7-
"test": "mocha --require @std/esm */test.js",
7+
"test": "mocha --require @std/esm 20*/*/test.js",
88
"precommit": "lint-staged"
99
},
1010
"lint-staged": {

0 commit comments

Comments
 (0)