MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / print_grid

Function print_grid

2018/src/10.py:4–14  ·  view source on GitHub ↗
(stars: list[list[int]])

Source from the content-addressed store, hash-verified

2import re
3
4def print_grid(stars: list[list[int]]) -> str | None:
5 ymin, ymax = min(s[1] for s in stars), max(s[1] for s in stars)
6 if ymax-ymin > 10:
7 return None
8 xmin, xmax = min(s[0] for s in stars), max(s[0] for s in stars)
9 grid = '\n'
10 for y in range(ymin,ymax+1):
11 grid += '\n'
12 for x in range(xmin,xmax+1):
13 grid += '█' if any(s[0]==x and s[1]==y for s in stars) else ' '
14 return grid
15
16@aoc.main('10')
17def main(indata: str) -> tuple[str,int]:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected