-
Convert String Into a Cipher of Dictionaries and Back Using "Dunder" Methods And Attributes
Hello, checkiomates🐱👤!
Welcome back to our weekly Python news digest. There is a series of two reversed encode/decode missions for your training and an article about "dunder" methods and attributes.
💡TIP:
At your profile, after clicking on big percent number of your progress, you may see module and methods you have already used in your shared solutions. If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
🏁MISSION:
Cipher Dict by spark856 - Tackle the challenge of converting plain text into a nested cipher dictionary. Unleash your coding prowess as you navigate through a series of intricate steps: from encoding text to UTF-8 and converting it to hexadecimal, to meticulously organizing decimal numbers into ascending and descending blocks. Each digit serves as a key in a specific nested dictionary.
get_cipher("hello") == {4: {4: {8: {3: {7: {0: {4: {}, 7: {}}, 2: {2: {}}}, 8: {3: {}}}}}}}
Cipher Dict (decryption) by spark856 - Prepare to exercise your coding finesse as you traverse through the intricacies of reversing the encryption process. From meticulously sorting keys in the correct order to adeptly navigating through alternating blocks of digits, each step unveils a piece of the puzzle. As you merge the decoded blocks into a decimal number, the true essence of the message begins to surface. Finally, with a stroke of conversion, the decimal transforms into a hexadecimal string, revealing the secrets embedded within the encrypted text.
get_plain({1: {6: {3: {}}},2: {6: {5: {}}, 9: {0: {}, 5: {}}},3: {4: {5: {}}},6: {6: {4: {}}}}) == 'python'
📖ARTICLE:
Every dunder method in Python - Python includes tons of dunder methods ("double underscore" methods) which allow us to deeply customize how our custom classes interact with Python's many features. What dunder methods could you add to your class to make it friendly for other Python programmers who use it?
👩💻CODE SHOT:
How do you think, what the following code does?
def ??????????(num: int) -> bool: l = len(text := str(num)) return sum(map(lambda i: int(i)**l, text)) == num
🙌 Thanks for your attention! Hope to meet you at CheckiO. We are really interested in your thoughts! Please, leave a comment below! ⤵
Welcome to CheckiO - games for coders where you can improve your codings skills.
The main idea behind these games is to give you the opportunity to learn by exchanging experience with the rest of the community. Every day we are trying to find interesting solutions for you to help you become a better coder.
Join the Game