magic_lobster_party

  • 0 Posts
  • 222 Comments
Joined 4 months ago
cake
Cake day: March 4th, 2024

help-circle








  • Time complexity is mostly useful in theoretical computer science. In practice it’s rare you need to accurately estimate time complexity. If it’s fast, then it’s fast. If it’s slow, then you should try to make it faster. Often it’s not about optimizing the time complexity to make the code faster.

    All you really need to know is:

    • Array lookup: O(1)
    • Single for loop: O(n)
    • Double nested for loop: O(n^2)
    • Triple nested for loop: O(n^3)
    • Sorting: O(n log n)

    There are exceptions, so don’t always follow these rules blindly.

    It’s hard to just “accidentally” write code that’s O(n!), so don’t worry about it too much.






  • When web development started to move away from jQuery towards Angular, React, Ember, Vue and all that shit I made the conscious decision to stay away from front end development. Well, I already made the decision after struggling aligning elements in all web browsers with CSS.

    I’m glad I made that decision.

    Simplicity is unsophisticated and lacking in many parts. The simplest solution to a problem is always the best solution. Choose simplicity. I’m begging you. Your future is begging you.

    This goes with all of programming. It’s rare someone makes a clever solution that doesn’t immediately turn into “technical debt”.


  • Bit shift magic.

    My guess is that all the individual characters of Hello World are found inside the 0xC894 number. Every 4 bits of x shows where in this number we can find the characters for Hello World.

    You can read x right to left. (Skip the rightmost 0 as it’s immediately bit shifted away in first iteration)

    3 becomes H 2 becomes e 1 becomes l 5 becomes o

    etc.

    I guess when we’ve exhausted all bits of x only 0 will be remaining for one final iteration, which translates to !