81
top 13 comments
sorted by: hot top controversial new old
[-] earmuff@lemmy.dbzer0.com 19 points 1 month 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.

[-] SzethFriendOfNimi@lemmy.world 13 points 1 month ago

But… does it pass all the tests?

[-] _stranger_@lemmy.world 14 points 1 month ago

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

[-] madcaesar@lemmy.world 3 points 1 month ago
[-] 48954246@lemmy.world 5 points 1 month ago* (last edited 1 month ago)

What would the output be for the following:

99 Beers on the Wall!

[-] AnUnusualRelic@lemmy.world 2 points 1 month ago

Or for "CAFÉ"?

[-] jet@hackertalks.com 7 points 1 month ago* (last edited 1 month ago)

This will not work on Unicode

Greek and Arabic have cases as well

[-] MoSal@lemm.ee 4 points 1 month ago

This will not work on Unicode

Correct.

Greek and Arabic have cases as well

Who told you that?

[-] jet@hackertalks.com 6 points 1 month ago

Brain fart, I meant Cyrillic but I wrote the wrong word! Good catch thanks!

[-] Binette@lemmy.ml 4 points 1 month ago
[-] cadekat@pawb.social 8 points 1 month ago* (last edited 1 month 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 3 points 1 month 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 2 points 1 month ago

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

this post was submitted on 22 Jul 2024
81 points (97.6% liked)

Programming Horror

1634 readers
1 users here now

Welcome to Programming Horror!

This is a place to share strange or terrible code you come across.

For more general memes about programming there's also Programmer Humor.

Looking for mods. If youre interested in moderating the community feel free to dm @Ategon@programming.dev

Rules

Credits

founded 1 year ago
MODERATORS