• earmuff@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    23
    ·
    4 months ago

    Now please publish it as a Node.js module and in 3 weeks, it will be in Top 10 most used modules, being used in 90% of Fortune 500 corporations.

    • MoSal@lemm.ee
      link
      fedilink
      arrow-up
      5
      ·
      4 months ago

      This will not work on Unicode

      Correct.

      Greek and Arabic have cases as well

      Who told you that?

    • cadekat@pawb.social
      link
      fedilink
      arrow-up
      8
      ·
      edit-2
      4 months ago

      This looks like O(n), because you don’t include constants when calculating Big-O. It’s still ~26 times slower than the implementation without the inner loop.

      This looks like O(n^2) because of the sub.

      I was right the first time. sub is “substring” and not “substitute”.

  • jh29a@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    3
    ·
    4 months ago

    here’s a more nuanced question: in school iirc my teacher was implementing terminal 2-human tic-tac-toe with us and used an only slightly less egregious 7-by-3 AND/OR gate to see whether any player had won. because I didn’t like all the repetition, my version iterated through a 7-by-3 list of lists of indecies instead. every toy programming problem I’ve seen since was so general that it didn’t go well with this kind of hardcoding either

    • jet@hackertalks.com
      link
      fedilink
      English
      arrow-up
      2
      ·
      4 months ago

      When creating an example for beginning programmers, sometimes using a very inefficient data structure is more illustrative and a helpful educational tool.

  • azi
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 months ago

    Honestly as long as literals are properly converted, I don’t see any other way to do this in an entirely encoding agnostic way