r/ADHD_Programmers • • May 04 '24

So stupid...

Post image
285 Upvotes

18 comments sorted by

48

u/AngryGrenades May 04 '24

This is actually quite sickening.

14

u/ScionEyed May 04 '24

As someone with little-to-no prior experience who has an interest in programming, I’m confused.

74

u/monocle_and_a_tophat May 04 '24

It's not even necessarily a programming thing.

The 1st example LOOKS symmetrical. It's two sets of parentheses closing inwards. But it makes more sense if you treat each parenthesis as equal to a unique letter like you would in a normal word. Look at the direction they open, and you get the following:

  • Open to the Right (R), Opens to the Left (L), Opens to the Right (R), Opens to the Left (L). Or, RLRL. "RLRL" is not a palindrome, because spelled backwards its "LRLR".

If you look at the second example though, again focusing on the direction the parentheses open and ignoring that visually it "looks" like gibberish, you get:

  • Opens Right (R), Opens Left (L), Opens Left (L), Opens Right (R), or RLLR. Which is a palindrome.

25

u/ScionEyed May 04 '24

This definitely made the most sense to me, thank you for the explanation!

8

u/monocle_and_a_tophat May 04 '24

Glad to help...it took me a while to figure it out too

6

u/barabbint May 04 '24

You could also argue that the comic is wrong, and the palindrome is ()().
Because parentheses doesn't work as letters, and ()() can be read as "open parenthesis, close parenthesis, open parenthesis, close parenthesis" if you read it backwards too, since the symbols should probably change meaning according to reading direction.

5

u/monocle_and_a_tophat May 04 '24

ya I know, but.....that's the original joke, ha

3

u/SilverTM May 04 '24

You’re really good at breaking problems down and explaining them. Good job!

4

u/reireireis May 04 '24

A palindrome is a string that spells the same forward and back

3

u/ScionEyed May 04 '24

Thank you, but that wasn’t exactly the cause of my confusion lol

Edit: wait, I think I got it. I’m not exactly well right now so sick brain has decided to forsake me.

1

u/vladvash May 04 '24

Pemdas bro.

The parenthesis are essentially wxclud in this case.

1

u/superluminary May 04 '24

Open close close open

12

u/phord May 04 '24

ABBA lied to us.

0

u/[deleted] May 04 '24

[deleted]

3

u/Chbphone55 May 04 '24

It is.

The parentheses sequence open, close, close, open is a palindrome. Idk if you just read it wrong or what.

Alternatively read as left, right, right, left.

2

u/IAmA_Nerd_AMA May 04 '24

No but repeating the characters in the reverse order is different.

()() = )()(

())( = ())(

But it looks weird to our brains because we want to lump parenthesized things together.

1

u/Alcamtar May 04 '24

I think it's the symmetry not the parentheses.

1

u/MoreOfAnOvalJerk May 04 '24 edited May 04 '24

Replace the () with a letters in your head and that will make it clearer.

Eg. “R == (“ and “L == )”

Then the string becomes “RLLR”. Which reads the same left-to-right and right-to-left.

The reason this screws with the brain is because for some reason, the brain doesn’t look at the ( and ) characters as arbitrary glyph shapes and instead sees them with directionality, like an arrow. A palindrome isn’t necessarily symmetric in terms of the lines used to draw the glyphs, it’s only symmetric with respect to the letters as whole. Somehow our brains shortcut palindrome recognition to thinking it also means symmetric lines and the clearly non-symmetric () characters, and the way we automatically see directionality in them messes with the mental shortcut of intuitively recognizing palindromes.

1

u/hawkinsst7 May 04 '24

And what's funny, it's tempting to say RLLR is symmetrical. I think it's because symmetry can be a physically observable property, and a palindrome is a more abstract symmetry; our brains just kind of incorrectly equate them.