Created
December 6, 2022 06:12
-
-
Save davur/742b63a6600581ccbdac1cc83c2e0659 to your computer and use it in GitHub Desktop.
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
# TIL: Rotate a list of strings (e.g. multi line string) | |
""" | |
lines = [ | |
'[B] [N] [H]', | |
'[V] [P] [T] [V] [P]', | |
'[W] [C] [T] [S] [H] [N]', | |
'[T] [J] [Z] [M] [N] [F] [L]', | |
'[Q] [W] [N] [J] [T] [Q] [R] [B]', | |
'[N] [B] [Q] [R] [V] [F] [D] [F] [M]', | |
'[H] [W] [S] [J] [P] [W] [L] [P] [S]', | |
'[D] [D] [T] [F] [G] [B] [B] [H] [Z]', | |
' 1 2 3 4 5 6 7 8 9 ', | |
] | |
""" | |
rotated = [''.join(row) for row in zip(*lines[::-1])] | |
""" | |
rotated = [ | |
' [[[[[[[[', | |
'1DHNQTWVB', | |
' ]]]]]]]]', | |
' ', | |
' [[[ ', | |
'2DWB ', | |
' ]]] ', | |
' ', | |
' [[[[[[ ', | |
'3TSQWJC ', | |
' ]]]]]] ', | |
' ', | |
' [[[[[[[ ', | |
'4FJRNZTP ', | |
' ]]]]]]] ', | |
' ', | |
' [[[[[[[ ', | |
'5GPVJMST ', | |
' ]]]]]]] ', | |
' ', | |
' [[[[[ ', | |
'6BWFTN ', | |
' ]]]]] ', | |
' ', | |
' [[[[[[[[', | |
'7BLDQFHVN', | |
' ]]]]]]]]', | |
' ', | |
' [[[[ ', | |
'8HPFR ', | |
' ]]]] ', | |
' ', | |
' [[[[[[[[', | |
'9ZSMBLNPH', | |
' ]]]]]]]]', | |
] | |
# now just look at line 1, 5, ... (every 4 lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment