this post was submitted on 14 Sep 2024
610 points (98.7% liked)

Programmer Humor

19463 readers
15 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

founded 1 year ago
MODERATORS
 
all 24 comments
sorted by: hot top controversial new old
[–] zkfcfbzr@lemmy.world 206 points 1 month ago (2 children)
[–] NeatNit@discuss.tchncs.de 240 points 1 month ago

Embedded for convenience:

[–] bamboo@lemmy.blahaj.zone 191 points 1 month ago (2 children)

Wow TIL about the use of underscore in an interactive session.

[–] Unbecredible@lemm.ee 30 points 1 month ago

whaaaaaaaa this is so tight. I use an interactive session as a calculator on my pc and always wish there was a way to refer to the last result.

[–] FauxPseudo@lemmy.world 10 points 1 month ago

$_ in bash is the most recent parameter Always look for the built in variables. They save time.

[–] Aatube@kbin.melroy.org 82 points 1 month ago (1 children)

The unicode people really knew what they were doing

[–] stebo02@lemmy.dbzer0.com 48 points 1 month ago (1 children)

no the best part is they didn't and this all happened by chznce

[–] Aatube@kbin.melroy.org 25 points 1 month ago (1 children)

That’s what they tell you.

[–] naught@sh.itjust.works 30 points 1 month ago

Big unicode doesn't want you to know this one simple trick

[–] otter@lemmy.ca 35 points 1 month ago (3 children)

Can anyone explain this one?

[–] Mirodir@discuss.tchncs.de 109 points 1 month ago* (last edited 1 month ago) (3 children)

Sure. You have to solve it from inside out:

  • not()....See comment below for this one, I was tricked ~~is a base function that negates what's inside (turning True to False and vice versa) giving it no parameter returns "True" (because no parameter counts as False)~~
  • str(x) turns x into a string, in this case it turns the boolean True into the text string 'True'
  • min(x) returns the minimal element of an iterable. In this case the character 'T' because capital letters come before non-capital letters, otherwise it would return 'e' (I'm not entirely sure if it uses unicode, ascii or something else to compare characters, but usually capitals have a lower value than non-capitals and otherwise in alphabetical order ascending)
  • ord(x) returns the unicode number of x, in this case turning 'T' into the integer 84
  • range(x) creates an iterable from 0 to x (non-inclusive), in this case you can think of it as the list [0, 1, 2, ....82, 83] (it's technically an object of type range but details...)
  • sum(x) sums up all elements of a list, summing all numbers between 0 and 84 (non-inclusive) is 3486
  • chr(x) is the inverse of ord(x) and returns the character at position x, which, you guessed it, is 'ඞ' at position 3486.

The huge coincidental part is that ඞ lies at a position that can be reached by a cumulative sum of integers between 0 and a given integer. From there on it's only a question of finding a way to feed that integer into chr(sum(range(x)))

[–] sjmarf@sh.itjust.works 102 points 1 month ago* (last edited 1 month ago)

not() is a base function that negates what’s inside (turning True to False and vice versa) giving it no parameter returns “True” (because no parameter counts as False)

Actually, not is an operator. It makes more sense if you write not() as not () - the () is an empty tuple. An empty tuple is falsy in Python, so not () evaluates to True.

[–] otter@lemmy.ca 5 points 1 month ago
[–] JustAnotherKay@lemmy.world 1 points 1 month ago

I'm not entirely sure if it uses Unicode, ASCII or something else...

I think I remember Automate the Boring Stuff with Python explaining that python uses ASCIIbetical order, but it's been a minute since I read that book

[–] sabreW4K3@lazysoci.al 52 points 1 month ago (1 children)

When you parse that code, it presents this ඞ symbol, which looks close enough to the famous characters from Among Us, the viral video game.

[–] DudeDudenson@lemmings.world 15 points 1 month ago (2 children)

What is the simbol supposed to be originally?

[–] jameseb@lemm.ee 26 points 1 month ago

That code point is U+0D9E SINHALA LETTER KANTAJA NAASIKYAYA. It's a letter in a writing system used in Sri Lanka.

[–] arudesalad@sh.itjust.works 10 points 1 month ago

Chr prints the unicode symbol associated with the inputted value (in python). The team name uses several operators to have the inputted value be the amogus character

[–] Dark_Dragon@lemmy.dbzer0.com 29 points 1 month ago

𐐘 🔫ඞ