Created
July 14, 2023 01:47
-
-
Save 0xilis/eeb894ac2c5ddda93c00e992365e0085 to your computer and use it in GitHub Desktop.
Meowify
This file contains hidden or 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
| # Snoolie K | |
| # meowifier | |
| # output raw bits of character | |
| def raw(character): | |
| character_ascii = ord(character) # Convert character to ASCII value | |
| binary_string = bin(character_ascii)[2:] # Convert ASCII value to binary string, remove the '0b' prefix | |
| raw_bits = [int(bit) for bit in binary_string] # Convert each binary digit to integer and add to the list | |
| return raw_bits | |
| # 16 bits | |
| def zeroPadding(raw_bytes): | |
| arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | |
| reverse_bytes = reversed(raw_bytes) | |
| index = len(arr) - 1 | |
| for bit in reverse_bytes: | |
| arr[index] = bit | |
| index -= 1 | |
| return arr | |
| # meowify | |
| def meowifierSingleChar(raw_bytes): | |
| newMeowifiedArray = [] | |
| unsolved = True | |
| index = 0 | |
| index2 = 0 | |
| while unsolved: | |
| if raw_bytes[index] == 0: | |
| if raw_bytes[index+1] == 0: | |
| newMeowifiedArray.append('m') | |
| else: | |
| newMeowifiedArray.append('e') | |
| else: | |
| if raw_bytes[index+1] == 0: | |
| newMeowifiedArray.append('o') | |
| else: | |
| newMeowifiedArray.append('w') | |
| index += 2 | |
| index2 += 1 | |
| if index >= len(raw_bytes): | |
| unsolved = False | |
| return ''.join(newMeowifiedArray) | |
| def meowifier(string): | |
| stringList = list(string) | |
| newMeowifiedString = [] | |
| for character in stringList: | |
| newMeowifiedString.append(meowifierSingleChar(zeroPadding(raw(character)))) | |
| return ' '.join(newMeowifiedString) | |
| # raw bits to character | |
| def convert_to_character(raw_bits): | |
| binary_string = ''.join(str(bit) for bit in raw_bits) # Convert the list of bits to a binary string | |
| character_ascii = int(binary_string, 2) # Convert the binary string to an integer | |
| character = chr(character_ascii) # Convert the integer to a character | |
| return character | |
| def demeowifier(string): | |
| stringList = list(string) | |
| raw_bits = [] | |
| originalString = [] | |
| for character in stringList: | |
| if character == 'm': | |
| raw_bits.append(0) | |
| raw_bits.append(0) | |
| elif character == 'e': | |
| raw_bits.append(0) | |
| raw_bits.append(1) | |
| elif character == 'o': | |
| raw_bits.append(1) | |
| raw_bits.append(0) | |
| elif character == 'w': | |
| raw_bits.append(1) | |
| raw_bits.append(1) | |
| elif character == ' ': | |
| originalString.append(convert_to_character(raw_bits)) | |
| raw_bits = [] | |
| else: | |
| print("ERROR! non meow string passed in! this is *bad*!") | |
| print("the problem character: " + str(character)) | |
| originalString.append(convert_to_character(raw_bits)) | |
| raw_bits = [] | |
| return ''.join(originalString) | |
| print(meowifier(input("input something: "))) #mmmmemom mmmmeooe mmmmmomm mmmmeooe mmmmeowe mmmmmomm mmmmeemw mmmmeowo mmmmeoww mmmmeoww mmmmeowm mmmmeooe mmmmeoee | |
| print(demeowifier(input("input something: "))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment