this post was submitted on 04 Jun 2025
1014 points (98.6% liked)
Programmer Humor
23855 readers
2537 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Lets fix it. I think that since we are removing the ones, then "11" - 1 should be equal to "".
Should it, or should it be "1"? (just removing one, one)
Which "1" did it remove? And did it search the string to find a "1" to remove, or did it remove whichever character happened to be at array index 1?
The one at the end. Subtraction is the opposite of addition. If addition adds a character to the end of the string, it must follow that subtraction would remove a character from the end of the string.
This is how we end up with an endian schism
It should just randomly pick any "1". Add a bit of spice, you know
maybe we removed the last n characters
Hear me out:
"11" - 1 = "11" - (-1) = "11" (did not find "-1" in "11)
Or
"11" - 1 = "11" - (-1) = "1" (removed first "1")