Add files via upload
This commit is contained in:
parent
bc4aeacb27
commit
907d62c912
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@
|
||||
"from collections import Counter, defaultdict, namedtuple, deque, abc\n",
|
||||
"from dataclasses import dataclass, field\n",
|
||||
"from itertools import permutations, combinations, cycle, chain, islice\n",
|
||||
"from itertools import count as count_from, product as cross_product\n",
|
||||
"from itertools import count as count_from, product as cross_product, takewhile\n",
|
||||
"from typing import *\n",
|
||||
"from statistics import mean, median\n",
|
||||
"from math import ceil, floor, factorial, gcd, log, log2, log10, sqrt, inf, atan2\n",
|
||||
@ -168,7 +168,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 78,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -200,17 +200,13 @@
|
||||
" f' WRONG; expected answer is {self.solution}')\n",
|
||||
" return f'Puzzle {self.puzzle:4.1f}: {secs} seconds, answer {self.got:<15}{comment}'\n",
|
||||
"\n",
|
||||
"def report(answers):\n",
|
||||
"def summary(answers):\n",
|
||||
" \"\"\"Print a report that summarizes the answers.\"\"\"\n",
|
||||
" for d in sorted(answers):\n",
|
||||
" print(answers[d])\n",
|
||||
" secs = sum(answers[d].secs for d in answers)\n",
|
||||
" print(f'\\nTotal time {secs:.4f} seconds, Mean time {secs/len(answers):.4f} seconds')\n",
|
||||
"\n",
|
||||
"def test_answer():\n",
|
||||
" print(answer(0.1, unknown))\n",
|
||||
" print(answer(0.2, 2**39, lambda: 2**39))\n",
|
||||
" print(answer(0.3, 2**39, lambda: 2**39+1))\n",
|
||||
" print(answer(10.4, unknown, lambda: 2 + 2))"
|
||||
" times = [answers[d].secs for d in answers]\n",
|
||||
" print(f'\\nCorrect: {quantify(answers[d].ok for d in answers)}/{len(answers)}')\n",
|
||||
" print(f'\\nTime in seconds: {median(times):.4f} median, {mean(times):.4f} mean, {sum(times):.4f} total.')"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -581,6 +577,8 @@
|
||||
" \"\"\"Print a representation of the grid.\"\"\"\n",
|
||||
" for row in self.to_rows(xrange, yrange):\n",
|
||||
" print(*row, sep=sep)\n",
|
||||
"\n",
|
||||
" def __str__(self): return cat(self.to_rows())\n",
|
||||
" \n",
|
||||
" def plot(self, markers={'#': 's', '.': ','}, figsize=(14, 14), **kwds):\n",
|
||||
" \"\"\"Plot a representation of the grid.\"\"\"\n",
|
||||
|
Loading…
Reference in New Issue
Block a user