• @[email protected]
    link
    fedilink
    202 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.

    • @[email protected]
      link
      fedilink
      8
      edit-2
      2 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”.

  • @[email protected]
    link
    fedilink
    32 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

    • @[email protected]
      link
      fedilink
      English
      22 months ago

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