diff --git a/src/Year_2016/P8.py b/src/Year_2016/P8.py index 0f41041..879ad19 100644 --- a/src/Year_2016/P8.py +++ b/src/Year_2016/P8.py @@ -90,9 +90,11 @@ def rotate_row(instruction: str, grid: npt.NDArray[int]) -> npt.NDArray[int]: grid[int(y) : int(y) + 1, :] = new_row +# dimensions given by the problem +init_grid = np.zeros((6, 50), dtype=int) + + def part_1() -> None: - # dimensions given by the problem - init_grid = np.zeros((6, 50), dtype=int) for instruction in instructions: if instruction.startswith("rect"): @@ -107,5 +109,25 @@ def part_1() -> None: print(f"There should be {lit} pixels lit") +# --- Part Two --- + +# You notice that the screen is only capable of displaying capital letters; in +# the font it uses, each letter is 5 pixels wide and 6 tall. + +# After you swipe your card, what code is the screen trying to display? + + +def display(grid): + print( + "\n".join("".join("X" if one else " " for one in row) for row in grid) + ) + + +def part_2() -> None: + print("The code is the following:\n") + display(init_grid) + + if __name__ == "__main__": part_1() + part_2()