Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
14-liner: imaginary solution in Clear category for Matrix "Hatching" by przemyslaw.daniel
from typing import List
from itertools import product
from collections import defaultdict
def hatching(matrix: List[List[int]]) -> List[List[int]]:
height, width = len(matrix), len(matrix[0])
result = defaultdict(list)
for x, y in product(range(width), range(height)):
result[((1j*x + y)*(1 + 1j)).imag] += [matrix[y][x]]
return list(result.values())
Dec. 2, 2022
Comments: