Add files via upload
This commit is contained in:
parent
e1bd865098
commit
69cc3ce239
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"from collections import Counter, defaultdict, namedtuple, deque, abc\n",
|
"from collections import Counter, defaultdict, namedtuple, deque, abc\n",
|
||||||
"from dataclasses import dataclass, field\n",
|
"from dataclasses import dataclass, field\n",
|
||||||
"from itertools import permutations, combinations, cycle, chain, islice\n",
|
"from itertools import permutations, combinations, cycle, chain, islice, filterfalse\n",
|
||||||
"from itertools import count as count_from, product as cross_product, takewhile\n",
|
"from itertools import count as count_from, product as cross_product, takewhile\n",
|
||||||
"from typing import *\n",
|
"from typing import *\n",
|
||||||
"from statistics import mean, median\n",
|
"from statistics import mean, median\n",
|
||||||
@ -173,7 +173,6 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"answers = {} # `answers` is a dict of {puzzle_number: answer}\n",
|
"answers = {} # `answers` is a dict of {puzzle_number: answer}\n",
|
||||||
"\n",
|
|
||||||
"unknown = 'unknown'\n",
|
"unknown = 'unknown'\n",
|
||||||
"\n",
|
"\n",
|
||||||
"class answer:\n",
|
"class answer:\n",
|
||||||
@ -754,7 +753,12 @@
|
|||||||
" \n",
|
" \n",
|
||||||
"class HCounter(Counter):\n",
|
"class HCounter(Counter):\n",
|
||||||
" \"\"\"A Counter, but it is hashable.\"\"\"\n",
|
" \"\"\"A Counter, but it is hashable.\"\"\"\n",
|
||||||
" def __hash__(self): return hash(tuple(sorted(self.items())))"
|
" def __hash__(self): return hash(tuple(sorted(self.items())))\n",
|
||||||
|
"\n",
|
||||||
|
"class EqualityIsIdentity:\n",
|
||||||
|
" \"\"\"A mixin to say that objects of this class are equal only if they are identical.\"\"\"\n",
|
||||||
|
" def __hash__(self): return id(self)\n",
|
||||||
|
" def __eq__(self, other): return self is other"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -766,7 +770,7 @@
|
|||||||
"class Graph(defaultdict):\n",
|
"class Graph(defaultdict):\n",
|
||||||
" \"\"\"A graph of {node: [neighboring_nodes...]}. \n",
|
" \"\"\"A graph of {node: [neighboring_nodes...]}. \n",
|
||||||
" Can store other kwd attributes on it (which you can't do with a dict).\"\"\"\n",
|
" Can store other kwd attributes on it (which you can't do with a dict).\"\"\"\n",
|
||||||
" def __init__(self, contents, **kwds):\n",
|
" def __init__(self, contents=(), **kwds):\n",
|
||||||
" self.update(contents)\n",
|
" self.update(contents)\n",
|
||||||
" self.default_factory = list\n",
|
" self.default_factory = list\n",
|
||||||
" self.__dict__.update(**kwds)"
|
" self.__dict__.update(**kwds)"
|
||||||
|
Loading…
Reference in New Issue
Block a user