-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from amclin/feature/2018-day-14
Feature/2018 day 14 part 2
- Loading branch information
Showing
5 changed files
with
168 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
const { | ||
calculateXAfterY, | ||
findPattern, | ||
loopRecipesForElves, | ||
Recipes | ||
} = require('./recipes') | ||
|
||
const input = 540561 | ||
|
||
const elves = [3, 7] | ||
const recipes = new Recipes(elves[0]) | ||
let recipes = new Recipes([3, 7]) | ||
|
||
elves.forEach((elf, idx) => { | ||
if (idx === 0) { | ||
elves[0] = recipes.head | ||
} else { | ||
elves[idx] = recipes.addRecipe(elf) | ||
} | ||
}) | ||
|
||
const answer = calculateXAfterY(10, input, recipes, elves) | ||
const answer2 = '' | ||
const answer = calculateXAfterY(10, input, recipes) | ||
|
||
console.log(`-- Part 1 --`) | ||
console.log(`Answer: ${answer}`) | ||
|
||
recipes = new Recipes([3, 7]) | ||
while (recipes.length < 3000) { | ||
loopRecipesForElves(recipes, 1) | ||
} | ||
|
||
recipes = new Recipes([3, 7]) | ||
const bufferSize = 10000 | ||
const answer2 = findPattern(input.toString(), recipes, bufferSize) | ||
console.log(`-- Part 2 --`) | ||
console.log(`Answer: ${answer2}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) | ||
[![Build Status](https://travis-ci.org/amclin/advent-of-code.svg?branch=master)](https://travis-ci.org/amclin/advent-of-code) | ||
[![codecov](https://codecov.io/gh/amclin/advent-of-code/branch/master/graph/badge.svg)](https://codecov.io/gh/amclin/advent-of-code) | ||
|
||
### Special Instructions | ||
|
||
#### Day 14 | ||
Day 14 is fast but needs more memory to complete. Run node with 4GB of heap space: | ||
`node --max_old_space_size=4096 index.js` |
Oops, something went wrong.