def constrain_2d_tuple(tup: Tuple[Tuple[any, ...], ...], rows: int, columns: int,
flip_before_constrain: bool = False, empty_fill=0):
return tuple([tuple([(tup[::-1][j][i] if flip_before_constrain else tup[j][i]) if i < len(tup[j]) else
empty_fill for i in range(rows)]) if j < len(tup) else tuple([empty_fill for _ in range(rows)]
) for j in range(columns)])
17
u/Masynchin Sep 02 '21
Source is bad, but PyCharm formatter made it even 10x worse
12
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Sep 02 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
7
u/trinopoty Sep 02 '21
I can proudly say that I write bad code, but not as bad as some of the stuff I see here.
4
u/[deleted] Sep 03 '21
That seems like a lot of bs just to flip some tuple values around
3
u/RedditAcc-92975 Sep 02 '21
I think I got brain damage from trying to comprehend this.