This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
SIZE = 8 | |
def knight_distance(i: int, j: int) -> list[list[int]]: | |
board = [[None] * SIZE for _ in range(SIZE)] | |
q = deque([(i, j, 0)]) | |
while q: | |
(i, j, d) = q.popleft() | |
if not 0 <= i < SIZE or not 0 <= j < SIZE or board[i][j] is not None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import mkdir | |
import sys | |
class AuxState: | |
def __init__(self, root): | |
self.id = '⊥' | |
self.root = root | |
self.suffix_link = None | |
self.transitions = {'*': self.root} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
SYMBOLS = { | |
'0': (1, 1, 1, 1, 1, 1, 0, 0, 0, 0), | |
'1': (0, 0, 0, 1, 1, 0, 0, 0, 0, 0), | |
'2': (1, 0, 1, 1, 0, 1, 1, 0, 0, 0), | |
'3': (0, 0, 1, 1, 1, 1, 1, 0, 0, 0), | |
'4': (0, 1, 0, 1, 1, 0, 1, 0, 0, 0), | |
'5': (0, 1, 1, 0, 1, 1, 1, 0, 0, 0), | |
'6': (1, 1, 1, 0, 1, 1, 1, 0, 0, 0), |