Hi, I’m Shauna! I’m a 37 year old transgender woman from Ontario, Canada. I’m also a Linux enthusiast, and a Web Developer by trade. Huge Star Trek fan, huge Soulsborne fan, and all-around huge nerd.

  • 0 Posts
  • 11 Comments
Joined 2 years ago
cake
Cake day: June 15th, 2023

help-circle





  • It’s not at all necessary, but I find it makes much easier to read code if you instead only use if statements and just return early when you’re in a function. For example, you could check isalpha(letter) == true is true then check letter + key <= 90 do the letter += key; return letter; then since letter + key must be > 90 if it didn’t already return a value, then you can do the while statement and return letter without needing an if statement at all. Then the isalpha(letter) == false is also unncessary, just return letter at the end.

    Like this:

    char rotate(char letter, int key)
    {
      if (isalpha(letter)
      {
        if (letter  + key <= 90)
        {
            letter += key;
            return letter;
        }
    
        do the while loop here
      }
    
      return letter;
    }
    
    

  • Yeah, we’re what’s known as persistence hunters. The main thing limiting animals in distance is overheating, and Humans have the best cooling system in the entire animal kingdom with our entire bodies covered in sweat glands and little hair to hold in heat. We’re designed not to be the fastest, or the strongest, but to outlast. We chase our prey until it gives up from exhaustion.

    Probably a big part of why we evolved intelligence is that it’s important to be able to track your prey as a persistence hunter. Being able to notice patterns like a snapped branch means the prey went that way, or recognizing animal prints would have played a huge part in who survived so it was selected for.




  • This is a pretty compact and - I think - easy to read way of doing it:

    while(display != list(chosen_word)):

    guess = input("Guess a letter: ").lower()

    display = list(map(lambda c, d: c if d != '_' or c == guess else d, chosen_word, display))

    print(display)

    print("Congrats! You did it!")

    Mapping over an array is a pretty powerful tool and also using ternary expressions. If you’re not familiar, a map basically just iterates over an array and runs a function on that item, replacing it with whatever the return value of the function is.

    For example:

    ones = [1, 1] twos = list(map(lambda n: n + 1, ones))

    It’s running the lambda function with n as a parameter and returning n + 1, and it’s pulling the numbers from the array “ones”.

    Then ternary expressions I also find quite powerful. The format of which is basically:

    (result if true) if (condition to check) else (result of false)

    Or:

    2 if 1 + 1 == 2 else "You broke math. How did you do that?"