-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
-iQIcBAABCAAGBQJWcZFhAAoJEJPB2e07PgbqwYIP/RWVC7z0YVqng3AAxDSAOMiT
-rF/h11os8AcMBqg3Yk2dMc5i287by6sf/jWdDvZNJCFBxlYl68Z2ay8+I3OVCzxM
-eTKUMcsCoBg5LYpojhYC+IxM+38guH6mo7aJbXpGlca9cReZ/FiYoMTNTNvNNMPC
-a/sgy1wPnek9MKs5/1w7vehiDHwFaFK6BH38mH/TBchg/oPQFCdLWT/0/pcbgDen
-NEw0zwyWhPXI3imSrr/nUkxKR+AMd9WLnXz/RHf62pfzUYD53Wlm732qErISJK9N
-H1xYYVXMkwLcIW1Owus4zyXgBiB3ltSoxtA/If30e6L8R3Uq59eaPtoyMk/5zIdI
-1Lv/+zYEJ3SobXEAeADbCTOXQGy0qy7byRaLQdgcvcFo+24kJJF4UCMOjlBhjEO+
-7zhLnRQgjWOcQDWLm6YdaSZDP3hn1JVDN3mY76gMVBE2WXnIQ/J0Qipq8DRrb18y
-ZCnodUfeQbEylP1mLrulGOLu2hDn2d1FcaHMHF1CfJVQILmkLmLx2q+ZauiQePp3
-ELF0QCwqsbCLgk7BTpwgnOgz0wUVQ/Yz3GXrmnLBAruXCOJmEgqg8UOoBherBhVW
-e+tvN53HHuefmqofOsTpWJOFxl3MKaUO0dcLtKypcYuiGQL4qY7VUsKTrTxpe45u
-YABZaJJLrdbsk6tVZF6p
-=owuV
+iQIcBAABCAAGBQJWcqV1AAoJEJPB2e07PgbqYfAP/39bUeBl1qguTBD//XGVr7zH
+DnRsyDbc0N26BDxyl3BtGMVKNO4TC0cSoGz5ENMvd3UX4NkAMDkH6yXE+IWq8f54
+E5LZ/ldTx4LMRT9UsVa+ZWxqu+Af7pxCrGovl7eviFzZSGBAJnUSGzX2oW/dkkPd
+YucVYlI+bnLtvUUvFQvHjlqcd6q13yzbM3pc2rPRNWmdN/CQCi/SPNsgeba4IEI8
+nKyBJB7Y4VZei8pOP0ACrq//5TbgIPRZ0GCGyznGRAUeNowxZiItSuOwYV9LwEaM
+q+gatYTUoWeBgvdW2w51MSxDZyckQ9D/rDHFr4c+NIgBQ9J3SX/jROv2HwTo2mV9
+0uwipt3jQy5JuXEyPFfs0QtZWwmt0/cESpd5AisQcV2KFvTokZoKOXwBptgR9gTD
+Zpgcooh3QuwLlofH09xf/cA4Jhl/4xZHcgZR6lb1hLFDKPvNOCX4g1ZgV69gLvv8
+1riocPuOTsryjvwnTmbPkMyg3v61sxxEWdQCEmddIpYa/Y7xpBu8lA3DbKyFhiHR
+K+klaJS1um1K9UoGp7UzFmb+3xYPSuTkSKsq6xMqNN7mKivXFRNCH5Brqo0tjiGN
+k71NZhR6ySDTlijboVszfttBUazke+2hDzMpj3VU6/zp4Ah6cFZnpckisq5EfE9I
+2R4HZ3QF0cFMtvzmmvur
+=OtaE
-----END PGP SIGNATURE-----
```
5919 advent-of-code-12.html cc84ec3c04da02c7d566f7c0f3ea08a4abf57f2931d7dc87915b2a88d1944e8c
7192 advent-of-code-13.html 9b84752c8f387cd03f85299c78837cea35c64a0276db7dbef9e33f82971b47e2
6940 advent-of-code-14.html 434d5f7542d85beb72a03306cfa7d43e18a7857d4e031018747249e2edc00355
-8545 advent-of-code-15.html ce34ca2c904d7a1d99fe3bc15dffa1a084e7e07248a46e6b50aacb623e4a6c9d
+7384 advent-of-code-15.html 4a8f850bcd4e54fd9d95e7e102f6a6fe796badd9032ba4525b05a641015172cf
advent-of-code-15_files/
821 css 2b2caac1348f4fe3e6c58c5fcbeaf56f12a704c07efacb39ae81980f69f285a0
11201 style.css 6a0bf14bde57190ab82dc93d43e04753da916ca3cdd4b8cb9c063616c789df94
7064 advent-of-code-16.html 86e6c27d7688f3aa99bc465b6e14af6cd06f4153f6c742d71a3ed7fb1d0aa39c
+5613 advent-of-code-17.html dc164050b1accefbbf8f2a8c13428df348bdc22d4293fcf4ef9fc6b74d38a227
109395 advent-of-code.ipynb 7292eeb9a8019f6931037c70105ab96bf691074dbe963736b6429cb4d4373f51
25607 advent01.ipynb c33ad39a77803a6870dd74998da98e3bb9c2c2db37c34167b330a01d663717e7
7001 advent01.txt 79312922877bdedd09ce0886a42b3d7f7ed092e2218579fb7d6ac1cb38cedebe
274 advent15.txt 7a8a96fd6321651f56df6018bf9c9ba3670af027504e294906d68b34ccff3910
4262 advent16.ipynb d3cd7fd1f418a757a278ad0702d95af8e61a1cb3778b865c8e4cd98ab834097b
21628 advent16.txt 90d5da4140bf7c7e98c16d78b3249b0e69da7efe9fb5c69a4a0757f1e3552f94
+7135 advent17.ipynb 8acc02e3cc58bed5263dd7261f1edef3475771ba9def1b533319ce63d7d8944d
+59 advent17.txt 9ea23339652ff398a7c97d7a7303ab2deee04c3e23a6c599106d65b6b89e52df
```
#### Ignore
<!DOCTYPE html>
-<!-- saved from url=(0030)http://adventofcode.com/day/15 -->
-<html lang="en-us"><script async="" src="http://www.google-analytics.com/analytics.js"></script><script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<meta charset="utf-8">
+<html lang="en-us">
+<head>
+<meta charset="utf-8"/>
<title>Day 15 - Advent of Code</title>
<!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]-->
-<link href="./advent-of-code-15_files/css" rel="stylesheet" type="text/css">
-<link rel="stylesheet" type="text/css" href="./advent-of-code-15_files/style.css">
-<link rel="shortcut icon" href="http://adventofcode.com/favicon.ico?2">
-<style type="text/css">:root .adsbygoogle
-{display:none !important;}</style><style type="text/css"></style><style id="style-1-cropbar-clipper">/* Copyright 2014 Evernote Corporation. All rights reserved. */
-.en-markup-crop-options {
- top: 18px !important;
- left: 50% !important;
- margin-left: -100px !important;
- width: 200px !important;
- border: 2px rgba(255,255,255,.38) solid !important;
- border-radius: 4px !important;
-}
-
-.en-markup-crop-options div div:first-of-type {
- margin-left: 0px !important;
-}
-</style><link rel="stylesheet" type="text/css" href="chrome-extension://pkehgijcmpdhfbdbbnkijodmdjhbjlgp/skin/socialwidgets.css"></head><!--
+<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
+<link rel="stylesheet" type="text/css" href="/static/style.css?3"/>
+<link rel="shortcut icon" href="/favicon.ico?2"/>
+</head><!--
-->
<body>
-<header><h1><a href="http://adventofcode.com/">Advent of Code</a></h1><div class="user">Neil Smith <span class="star-count">30*</span></div><nav><ul><li><a href="http://adventofcode.com/about">[About]</a></li><li><a href="http://adventofcode.com/stats">[Stats]</a></li><li><a href="http://adventofcode.com/leaderboard">[Leaderboard]</a></li><li><a href="http://adventofcode.com/settings">[Settings]</a></li><li><a href="http://adventofcode.com/auth/logout">[Log out]</a></li></ul></nav></header>
+<header><h1><a href="/">Advent of Code</a></h1><div class="user">Neil Smith <span class="star-count">34*</span></div><nav><ul><li><a href="/about">[About]</a></li><li><a href="/stats">[Stats]</a></li><li><a href="/leaderboard">[Leaderboard]</a></li><li><a href="/settings">[Settings]</a></li><li><a href="/auth/logout">[Log out]</a></li></ul></nav></header>
<div id="ad">
-<script async="" src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
+<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Advent of Code Wide Skyscraper -->
-<ins class="adsbygoogle" style="width: 160px; height: 600px;" data-ad-client="ca-pub-9420604735624631" data-ad-slot="8014013294"></ins>
+<ins class="adsbygoogle"
+ style="display:inline-block;width:160px;height:600px"
+ data-ad-client="ca-pub-9420604735624631"
+ data-ad-slot="8014013294"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>Given the ingredients in your kitchen and their properties, what is the <em>total score</em> of the highest-scoring cookie you can make with a calorie total of <code>500</code>?</p>
</article>
<p>Your puzzle answer was <code>15862900</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
-<p>At this point, you should <a href="http://adventofcode.com/">return to your advent calendar</a> and try another puzzle.</p>
-<p>If you still want to see it, you can <a href="http://adventofcode.com/day/15/input" target="_blank">get your puzzle input</a>.</p>
+<p>At this point, you should <a href="/">return to your advent calendar</a> and try another puzzle.</p>
+<p>If you still want to see it, you can <a href="/day/15/input" target="_blank">get your puzzle input</a>.</p>
<p>You can also <span class="share">[Share<span class="share-content">on
- <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Science+for+Hungry+People%22+%2D+Day+15+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15&related=ericwastl&hashtags=AdventOfCode" target="_blank" rel="noreferrer">Twitter</a>
- <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15" target="_blank" rel="noreferrer">Google+</a>
- <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15&title=I%27ve+completed+%22Science+for+Hungry+People%22+%2D+Day+15+%2D+Advent+of+Code" target="_blank" rel="noreferrer">Reddit</a></span>]</span>
+ <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Science+for+Hungry+People%22+%2D+Day+15+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15&related=ericwastl&hashtags=AdventOfCode" target="_blank">Twitter</a>
+ <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15" target="_blank">Google+</a>
+ <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15&title=I%27ve+completed+%22Science+for+Hungry+People%22+%2D+Day+15+%2D+Advent+of+Code" target="_blank">Reddit</a
+></span>]</span>
this puzzle.</p>
</main>
ga('send', 'pageview');
</script>
<!-- /ga -->
-
-
-</body></html>
\ No newline at end of file
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html lang="en-us">
+<head>
+<meta charset="utf-8"/>
+<title>Day 17 - Advent of Code</title>
+<!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]-->
+<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
+<link rel="stylesheet" type="text/css" href="/static/style.css?3"/>
+<link rel="shortcut icon" href="/favicon.ico?2"/>
+</head><!--
+
+
+
+
+Oh, hello! Funny seeing you here.
+
+I appreciate your enthusiasm, but you aren't going to find much down here.
+There certainly aren't clues to any of the puzzles. You do risk spoiling a few
+surprises for yourself, though. Best to play the normal way and discover
+everything as it was intended, I think. The best surprises don't even appear
+in the source until you unlock them for real.
+
+Please be careful with automated requests; I'm not Google, and I can only take
+so much traffic. Please be considerate so that everyone gets to play.
+
+If you're curious about how Advent of Code works, it's running on some custom
+Perl code. Other than a few integrations (auth, analytics, ads, social media),
+I built the whole thing myself, including the design, animations, prose, and
+all of the puzzles.
+
+The puzzles probably took the longest; the easiest ones were around 45 minutes
+each, but the harder ones took 2-3 hours, some even longer than that. A lot of
+effort went into building this thing - I hope you're enjoying playing it as
+much as I enjoyed making it for you!
+
+If you'd like to hang out, I'm @ericwastl on Twitter.
+
+- Eric Wastl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+-->
+<body>
+<header><h1><a href="/">Advent of Code</a></h1><div class="user">Neil Smith <span class="star-count">34*</span></div><nav><ul><li><a href="/about">[About]</a></li><li><a href="/stats">[Stats]</a></li><li><a href="/leaderboard">[Leaderboard]</a></li><li><a href="/settings">[Settings]</a></li><li><a href="/auth/logout">[Log out]</a></li></ul></nav></header>
+
+<div id="ad">
+<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
+<!-- Advent of Code Wide Skyscraper -->
+<ins class="adsbygoogle"
+ style="display:inline-block;width:160px;height:600px"
+ data-ad-client="ca-pub-9420604735624631"
+ data-ad-slot="8014013294"></ins>
+<script>
+(adsbygoogle = window.adsbygoogle || []).push({});
+</script>
+</div><!--/ad-->
+
+<main>
+<article class="day-desc"><h2>--- Day 17: No Such Thing as Too Much ---</h2><p>The elves bought too much eggnog again - <code>150</code> liters this time. To fit it all into your refrigerator, you'll need to move it into smaller containers. You take an inventory of the capacities of the available containers.</p>
+<p>For example, suppose you have containers of size <code>20</code>, <code>15</code>, <code>10</code>, <code>5</code>, and <code>5</code> liters. If you need to store <code>25</code> liters, there are four ways to do it:</p>
+<ul>
+<li><code>15</code> and <code>10</code></li>
+<li><code>20</code> and <code>5</code> (the first <code>5</code>)</li>
+<li><code>20</code> and <code>5</code> (the second <code>5</code>)</li>
+<li><code>15</code>, <code>5</code>, and <code>5</code></li>
+</ul>
+<p>Filling all containers entirely, how many different <em>combinations of containers</em> can exactly fit all <code>150</code> liters of eggnog?</p>
+</article>
+<p>Your puzzle answer was <code>654</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>While playing with all the containers in the kitchen, another load of eggnog <span title="Apparently, Amazon ships to the North Pole now.">arrives</span>! The shipping and receiving department is requesting as many containers as you can spare.</p>
+<p>Find the minimum number of containers that can exactly fit all <code>150</code> liters of eggnog. <em>How many different ways</em> can you fill that number of containers and still hold exactly <code>150</code> litres?</p>
+<p>In the example above, the minimum number of containers was two. There were three ways to use that many containers, and so the answer there would be <code>3</code>.</p>
+<p></p>
+</article>
+<p>Your puzzle answer was <code>57</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
+<p>At this point, you should <a href="/">return to your advent calendar</a> and try another puzzle.</p>
+<p>If you still want to see it, you can <a href="/day/17/input" target="_blank">get your puzzle input</a>.</p>
+<p>You can also <span class="share">[Share<span class="share-content">on
+ <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22No+Such+Thing+as+Too+Much%22+%2D+Day+17+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17&related=ericwastl&hashtags=AdventOfCode" target="_blank">Twitter</a>
+ <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17" target="_blank">Google+</a>
+ <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17&title=I%27ve+completed+%22No+Such+Thing+as+Too+Much%22+%2D+Day+17+%2D+Advent+of+Code" target="_blank">Reddit</a
+></span>]</span>
+ this puzzle.</p>
+</main>
+
+<!-- ga -->
+<script>
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+ga('create', 'UA-69522494-1', 'auto');
+ga('send', 'pageview');
+</script>
+<!-- /ga -->
+</body>
+</html>
--- /dev/null
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[50, 44, 11, 49, 42, 46, 18, 32, 26, 40, 21, 7, 18, 43, 10, 47, 36, 24, 22, 40]"
+ ]
+ },
+ "execution_count": 1,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "containers = [int(c.strip()) for c in open('advent17.txt').readlines()]\n",
+ "containers"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "target = 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "654"
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "partials = []\n",
+ "for c in containers:\n",
+ " new_partials = []\n",
+ " for p in partials:\n",
+ " if sum(p) + c <= target:\n",
+ " new_partials += [[c] + p]\n",
+ " new_partials += [p]\n",
+ " if c <= target:\n",
+ " new_partials += [[c]]\n",
+ " partials = new_partials\n",
+ "solutions = list(filter(lambda p: sum(p) == target, partials))\n",
+ "len(solutions)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "4"
+ ]
+ },
+ "execution_count": 28,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "shortest_solution = min(len(s) for s in solutions)\n",
+ "shortest_solution"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": false,
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[[7, 49, 44, 50],\n",
+ " [10, 46, 44, 50],\n",
+ " [24, 32, 44, 50],\n",
+ " [40, 49, 11, 50],\n",
+ " [40, 49, 11, 50],\n",
+ " [47, 42, 11, 50],\n",
+ " [43, 46, 11, 50],\n",
+ " [40, 18, 42, 50],\n",
+ " [40, 18, 42, 50],\n",
+ " [26, 32, 42, 50],\n",
+ " [18, 40, 42, 50],\n",
+ " [40, 18, 42, 50],\n",
+ " [22, 36, 42, 50],\n",
+ " [36, 18, 46, 50],\n",
+ " [22, 32, 46, 50],\n",
+ " [47, 7, 46, 50],\n",
+ " [36, 18, 46, 50],\n",
+ " [47, 21, 32, 50],\n",
+ " [24, 36, 40, 50],\n",
+ " [36, 43, 21, 50],\n",
+ " [47, 10, 43, 50],\n",
+ " [40, 24, 36, 50],\n",
+ " [46, 49, 11, 44],\n",
+ " [36, 21, 49, 44],\n",
+ " [47, 10, 49, 44],\n",
+ " [18, 46, 42, 44],\n",
+ " [18, 46, 42, 44],\n",
+ " [24, 40, 42, 44],\n",
+ " [43, 21, 42, 44],\n",
+ " [40, 24, 42, 44],\n",
+ " [24, 36, 46, 44],\n",
+ " [40, 40, 26, 44],\n",
+ " [47, 43, 49, 11],\n",
+ " [43, 40, 18, 49],\n",
+ " [40, 43, 18, 49],\n",
+ " [36, 47, 18, 49],\n",
+ " [43, 26, 32, 49],\n",
+ " [22, 47, 32, 49],\n",
+ " [40, 21, 40, 49],\n",
+ " [43, 18, 40, 49],\n",
+ " [40, 43, 18, 49],\n",
+ " [36, 47, 18, 49],\n",
+ " [22, 36, 43, 49],\n",
+ " [36, 26, 46, 42],\n",
+ " [22, 40, 46, 42],\n",
+ " [40, 22, 46, 42],\n",
+ " [47, 43, 18, 42],\n",
+ " [36, 40, 32, 42],\n",
+ " [40, 36, 32, 42],\n",
+ " [47, 21, 40, 42],\n",
+ " [40, 47, 21, 42],\n",
+ " [47, 43, 18, 42],\n",
+ " [43, 21, 40, 46],\n",
+ " [40, 24, 40, 46],\n",
+ " [40, 43, 21, 46],\n",
+ " [36, 47, 21, 46],\n",
+ " [24, 36, 47, 43]]"
+ ]
+ },
+ "execution_count": 29,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "[s for s in solutions if len(s) == shortest_solution]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "57"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "len([s for s in solutions if len(s) == shortest_solution])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 66,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": [
+ "import itertools"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 63,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "def int_to_bitstring(i, l):\n",
+ " bitstring = []\n",
+ " for _ in range(l):\n",
+ " if i & 1:\n",
+ " bitstring.append(True)\n",
+ " else:\n",
+ " bitstring.append(False)\n",
+ " i >>= 1\n",
+ " return reversed(bitstring)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 64,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[True, False, False, False, True, True, False, False]"
+ ]
+ },
+ "execution_count": 64,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "list(int_to_bitstring(140, 8))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 59,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[]"
+ ]
+ },
+ "execution_count": 59,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import itertools\n",
+ "valids = []\n",
+ "c_small = containers[:5]\n",
+ "for i in range(2**len(c_small)):\n",
+ " mask = int_to_bitstring(i, len(c_small))\n",
+ " cs = list(itertools.compress(c_small, mask))\n",
+ " if sum(cs) == target:\n",
+ " valids += [cs]\n",
+ "valids "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 65,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "654"
+ ]
+ },
+ "execution_count": 65,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import itertools\n",
+ "valids = []\n",
+ "for i in range(2**len(containers)):\n",
+ " mask = int_to_bitstring(i, len(containers))\n",
+ " cs = list(itertools.compress(containers, mask))\n",
+ " if sum(cs) == target:\n",
+ " valids += [cs]\n",
+ "len(valids)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.4.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}