Logo
CAPTCHA: Computers Asking People To Confirm Humanity Again
  • Home
  • Hot
  • Random
  • Search

Browse

  • AI AI
  • AWS AWS
  • Agile Agile
  • Algorithms Algorithms
  • Android Android
  • Apple Apple
  • Backend Backend
  • Bash Bash
  • C++ C++
  • Cloud Cloud
  • Csharp Csharp
  • All Categories
As an Amazon Associate ProgrammerHumor.io earns from qualifying purchases.

HTTP 418: I'm a teapot

The server identifies as a teapot now and is on a tea break, brb

HTTP 418: I'm a teapot

The server identifies as a teapot now and is on a tea break, brb

Hardcoded-solution Memes

Posts tagged with Hardcoded-solution

That's One Way To Do It I Guess...

Python Programming Debugging Testing Algorithms
21 days ago 368.5K views 0 shares
That's One Way To Do It I Guess...
So someone decided to detect a cycle in a linked list by just... checking if the head node's value is the letter 'E'. And wrapping it in a try-except that returns False on any exception. This solution somehow beats 5.18% on runtime and 7.89% on memory, which means there are actually worse solutions out there. For context, the proper way to detect cycles uses Floyd's cycle detection algorithm (the tortoise and hare approach), which runs in O(n) time with O(1) space. But why bother with elegant algorithms when you can just hardcode a character check that probably only works for one specific test case? The try-except is the cherry on top—because when your logic is this questionable, you might as well catch literally everything that could go wrong. The real mystery is what kind of test suite allows this to pass as "Accepted" with a green checkmark. Someone's edge cases need an edge case.

Today's picks

Either Experience Means Anything Or It Does Not

Either Experience Means Anything Or It Does Not

Programming
2.1M views 6 days ago
GearScouts.com

GearScouts.com

Sponsored
Power stations
deli Desk Organizer, Plastic Desktop Organizer with Pencil Holder and Sticky Note Tray, Office Stationery Supplies Organizers Accessories Caddy, 6 Compartments, Black

deli Desk Organizer, Plastic Desktop Organizer with Pencil Holder and Sticky Note Tray, Office Stationery Supplies Organizers Accessories Caddy, 6 Compartments, Black

Affiliate
$13.99