Skip to content

Commit baccc9d

Browse files
test(2018 day-14): test that recipes score correctly when multidigit
1 parent 05b7a9b commit baccc9d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

2018/day-14/recipes.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ describe('--- Day 14: Chocolate Charts ---', () => {
6161

6262
expect(expected).to.equal(actual)
6363
})
64+
it('handles when the score is multidigit', () => {
65+
const expected = '3710101245158916'
66+
67+
loopRecipesForElves(recipes, 10)
68+
// next should be multidigit
69+
loopRecipesForElves(recipes, 1)
70+
let actual = recipes.tail.value.toString()
71+
let iterator = recipes.tail.next
72+
while (iterator !== recipes.tail) {
73+
actual += iterator.value.toString()
74+
iterator = iterator.next
75+
}
76+
expect(recipes.length).to.equal(expected.length)
77+
expect(expected).to.equal(actual)
78+
})
6479
})
6580
describe('calculateXAfterY(x, y, recipe)', () => {
6681
it('predicts the next X results after the elves have executed Y', () => {

0 commit comments

Comments
 (0)