Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Creative category for Nonogram Encode by Tinus_Trotyl
def nonogram_encode(data: list[str]) -> list:
maxlen = lambda data: len(max(data, key=len))
formatted = lambda data: [(maxlen(data) - len(c)) * [0] + c for c in data]
tilt = [[len(c) for c in col.split()] for col in [''.join(list(seq)) for seq in zip(*list(data))]]
vertical = [(maxlen(tilt) - len(c)) * [0] + c for c in tilt]
horizontal = [[len(c) for c in col.split()] for col in data]
return [[list(c) for c in zip(*formatted(vertical))], formatted(horizontal)]
Sept. 23, 2022
Comments: