Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Last active January 5, 2016 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghaiklor/7f0f719d1d7eb62f529e to your computer and use it in GitHub Desktop.
Save ghaiklor/7f0f719d1d7eb62f529e to your computer and use it in GitHub Desktop.
Advent of Code (Day 17 Part 1)
const Combinatorics = require('./combinatorics');
const CONTAINERS = [11, 30, 47, 31, 32, 36, 3, 1, 5, 3, 32, 36, 15, 11, 46, 26, 28, 1, 19, 3];
let total = 0;
for (let i = 1; i < CONTAINERS.length - 1; i++) {
let combination = Combinatorics.combination(CONTAINERS, i);
let c = [];
while (c = combination.next()) {
if (c.reduce((a, b) => a + b) === 150) total++;
}
}
console.log(total);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment