• @[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.

    • @_stranger_
      link
      132 months ago

      If it does, they don’t have enough of the right tests.

        • @48954246
          link
          English
          5
          edit-2
          2 months ago

          What would the output be for the following:

          99 Beers on the Wall!

    • @[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
    22 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
      12 months ago

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