Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Last active January 5, 2016 16:41
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/bbcf27cf1deec34de037 to your computer and use it in GitHub Desktop.
Save ghaiklor/bbcf27cf1deec34de037 to your computer and use it in GitHub Desktop.
Advent of Code (Day 17 Part 2)
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].sort((a, b) => b - a);
const MIN_COUNT = 4;
let total = 0;
let combination = Combinatorics.combination(CONTAINERS, MIN_COUNT);
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