Advent 2017 through Day 12
This commit is contained in:
parent
548c1e21da
commit
d76d3b42ff
@ -1917,7 +1917,7 @@
|
||||
"\n",
|
||||
"# [Day 12](https://adventofcode.com/2017/day/12): Digital Plumber\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",
|
||||
"**Part Two**\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",
|
||||
"execution_count": 53,
|
||||
"execution_count": 56,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
@ -2020,13 +2020,13 @@
|
||||
"221"
|
||||
]
|
||||
},
|
||||
"execution_count": 53,
|
||||
"execution_count": 56,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len({min(G[i]) for i in G})"
|
||||
"len({Set(G[i]) for i in G})"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user