Tootfinder

Opt-in global Mastodon full text search. Join the index!

@scottmiller42@mstdn.social
2024-03-01 15:53:21

Due to my assumption that my code will (eventually) be used to train AI, I've been obfuscating my #LeetCode submissions.
Today, I figured out how to use the #Python walrus operator inside a list to mash variable assignment into a return statement. It's delightfully horrible. Check out this o…

This is a screenshot of some Python code that was deliberately written in a way to be confusing (aka, obfuscated):

from collections import Counter
def DoSomething (s:str) -> str:
    return [CharCount := Counter(s), 
            f"The string has {CharCount['0']} zeros."
            ][1]

#  This prints "The string has 4 zeros."
print (DoSomething ('00011110'))
@scottmiller42@mstdn.social
2024-02-23 18:11:18

In the last ~5 months, I've solved approximately 125 #LeetCode problems. I've learned a lot from this experience -- so much so that I've been thinking I need to write something to sum up what I've learned.
To some extent, what I've gained from all that coding is shifting knowledge from "I read this somewhere" to "I've experienced this first hand and now…