Advent 2017 through Day 12

This commit is contained in:
Peter Norvig
2017-12-12 14:49:56 -05:00
committed by GitHub
parent 548c1e21da
commit d76d3b42ff

View File

@@ -1917,7 +1917,7 @@
"\n", "\n",
"# [Day 12](https://adventofcode.com/2017/day/12): Digital Plumber\n", "# [Day 12](https://adventofcode.com/2017/day/12): Digital Plumber\n",
"\n", "\n",
"First I'll parse the data, creating a dict of `{program: direct_group_of_proggrams}`:" "First I'll parse the data, creating a dict of `{program: direct_group_of_programs}`:"
] ]
}, },
{ {
@@ -2004,12 +2004,12 @@
"\n", "\n",
"**Part Two**\n", "**Part Two**\n",
"\n", "\n",
"I did almost all the work; I just need to count the unique groups. The minimum value in a group uniquely identifies it, so:" "I did almost all the work; I just need to count the number of distinct groups. That's a set of sets, so I have to use my `Set` class (because regular `set`s are not hashable):"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 53, "execution_count": 56,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
@@ -2020,13 +2020,13 @@
"221" "221"
] ]
}, },
"execution_count": 53, "execution_count": 56,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"len({min(G[i]) for i in G})" "len({Set(G[i]) for i in G})"
] ]
} }
], ],