Add files via upload
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -25,7 +25,7 @@
|
|||||||
"from itertools import count as count_from, product as cross_product\n",
|
"from itertools import count as count_from, product as cross_product\n",
|
||||||
"from typing import *\n",
|
"from typing import *\n",
|
||||||
"from statistics import mean, median\n",
|
"from statistics import mean, median\n",
|
||||||
"from math import ceil, floor, factorial, gcd, log, log2, log10, sqrt, inf\n",
|
"from math import ceil, floor, factorial, gcd, log, log2, log10, sqrt, inf, atan2\n",
|
||||||
"\n",
|
"\n",
|
||||||
"import matplotlib.pyplot as plt\n",
|
"import matplotlib.pyplot as plt\n",
|
||||||
"import ast\n",
|
"import ast\n",
|
||||||
@@ -488,6 +488,10 @@
|
|||||||
" \"\"\"Specialized version of point addition for 2D Points only. Faster.\"\"\"\n",
|
" \"\"\"Specialized version of point addition for 2D Points only. Faster.\"\"\"\n",
|
||||||
" return (p[0] + q[0], p[1] + q[1])\n",
|
" return (p[0] + q[0], p[1] + q[1])\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"def sub2(p: Point, q: Point) -> Point: \n",
|
||||||
|
" \"\"\"Specialized version of point subtraction for 2D Points only. Faster.\"\"\"\n",
|
||||||
|
" return (p[0] - q[0], p[1] - q[1])\n",
|
||||||
|
"\n",
|
||||||
"def taxi_distance(p: Point, q: Point) -> int:\n",
|
"def taxi_distance(p: Point, q: Point) -> int:\n",
|
||||||
" \"\"\"Manhattan (L1) distance between two 2D Points.\"\"\"\n",
|
" \"\"\"Manhattan (L1) distance between two 2D Points.\"\"\"\n",
|
||||||
" return abs(p[0] - q[0]) + abs(p[1] - q[1])"
|
" return abs(p[0] - q[0]) + abs(p[1] - q[1])"
|
||||||
@@ -552,6 +556,11 @@
|
|||||||
" return (0 <= X_(point) < X_(self.size) and\n",
|
" return (0 <= X_(point) < X_(self.size) and\n",
|
||||||
" 0 <= Y_(point) < Y_(self.size))\n",
|
" 0 <= Y_(point) < Y_(self.size))\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
" def follow_line(self, start: Point, direction: Vector) -> Iterable[Point]:\n",
|
||||||
|
" while self.in_range(start):\n",
|
||||||
|
" yield start\n",
|
||||||
|
" start = add2(start, direction)\n",
|
||||||
|
"\n",
|
||||||
" def copy(self): \n",
|
" def copy(self): \n",
|
||||||
" return Grid(self, directions=self.directions, skip=self.skip, default=self.default)\n",
|
" return Grid(self, directions=self.directions, skip=self.skip, default=self.default)\n",
|
||||||
" \n",
|
" \n",
|
||||||
@@ -878,7 +887,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.8.15"
|
"version": "3.12.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user