Logo
My code doesn't work, I have no idea why. My code works, I have no idea why.
  • Home
  • Hot
  • Random
  • Search

Browse

  • AI AI
  • AWS AWS
  • Agile Agile
  • Algorithms Algorithms
  • Android Android
  • Apple Apple
  • Azure Azure
  • Backend Backend
  • Bash Bash
  • C++ C++
  • Cloud Cloud
  • 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

Cycle-detection Memes

Posts tagged with Cycle-detection

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

Python Programming Debugging Testing Algorithms
5 months ago 564.4K 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

Blue Light Blocking Amber Glasses for Sleep 99.9 Percent Effective - Nighttime Eye Wear - Special Orange Tinted Glasses Help You Sleep and Relax Your Eyes

Blue Light Blocking Amber Glasses for Sleep 99.9 Percent Effective - Nighttime Eye Wear - Special Orange Tinted Glasses Help You Sleep and Relax Your Eyes

Affiliate
$35.95
This pretty much sums it up.

This pretty much sums it up.

Debugging
56.7K views 4 years ago
Modern Realities

Modern Realities

Programming
95.4K views 2 years ago