Last active
January 5, 2016 16:41
-
-
Save ghaiklor/bbcf27cf1deec34de037 to your computer and use it in GitHub Desktop.
Advent of Code (Day 17 Part 2)
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
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