Created
November 9, 2023 13:19
-
-
Save hakoerber/10c3d74c7380948458cc0e8a33d47bf6 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
from pprint import pprint | |
l = "swssssswswwwssssswwsssswswwssswwswwswsssswwsswsw" | |
count_so = sum([1 if c == "s" else 0 for c in l]) | |
print(count_so) | |
count_wie = sum([1 if c == "w" else 0 for c in l]) | |
print(count_wie) | |
l = [0 if c == "s" else 1 for c in l] | |
chunks = 3 | |
digits_per_chunk = 2 | |
size = int(len(l) / chunks) | |
l = [l[i:i + size] for i in range(0,len(l),size)] | |
pprint(l) | |
l = [[c[i:i + 8] for i in range(0,len(c),8)] for c in l] | |
pprint(l) | |
l = [["".join([str(b) for b in d]) for d in c] for c in l] | |
l = [[int(b, 2) for b in c] for c in l] | |
l = ["".join([chr(b) for b in c]) for c in l] | |
pprint(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment