▲ 607 ▼ Sus (sh.itjust.works) submitted 2 years ago by sjmarf@sh.itjust.works to c/programmer_humor@programming.dev 22 comments fedilink hide all child comments
[–] otter@lemmy.ca 33 points 2 years ago (3 children) Can anyone explain this one? permalink fedilink source hideshow 6 child comments replies: [–] Mirodir@discuss.tchncs.de 109 points 2 years ago* (last edited 2 years 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))) permalink fedilink source parent hideshow 6 child comments replies: [–] sjmarf@sh.itjust.works [S] 100 points 2 years ago* (last edited 2 years 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. permalink fedilink source parent [–] otter@lemmy.ca 3 points 2 years ago Thank you! permalink fedilink source parent [–] JustAnotherKay@lemmy.world 1 point 2 years 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 permalink fedilink source parent [–] sabreW4K3@lazysoci.al 50 points 2 years ago (1 child) When you parse that code, it presents this ඞ symbol, which looks close enough to the famous characters from Among Us, the viral video game. permalink fedilink source parent hideshow 2 child comments replies: [–] DudeDudenson@lemmings.world 14 points 2 years ago (2 children) What is the simbol supposed to be originally? permalink fedilink source parent hideshow 4 child comments replies: [–] sabreW4K3@lazysoci.al 28 points 2 years ago (1 child) https://en.m.wiktionary.org/wiki/%E0%B6%9E permalink fedilink source parent hideshow 2 child comments replies: [–] degen@midwest.social 6 points 2 years ago Silly me, I thought it was gay permalink fedilink source parent [–] jameseb@lemm.ee 25 points 2 years ago That code point is U+0D9E SINHALA LETTER KANTAJA NAASIKYAYA. It's a letter in a writing system used in Sri Lanka. permalink fedilink source parent [–] arudesalad@sh.itjust.works 9 points 2 years 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 permalink fedilink source parent
[–] Mirodir@discuss.tchncs.de 109 points 2 years ago* (last edited 2 years 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))) permalink fedilink source parent hideshow 6 child comments replies: [–] sjmarf@sh.itjust.works [S] 100 points 2 years ago* (last edited 2 years 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. permalink fedilink source parent [–] otter@lemmy.ca 3 points 2 years ago Thank you! permalink fedilink source parent [–] JustAnotherKay@lemmy.world 1 point 2 years 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 permalink fedilink source parent
[–] sjmarf@sh.itjust.works [S] 100 points 2 years ago* (last edited 2 years 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. permalink fedilink source parent
[–] JustAnotherKay@lemmy.world 1 point 2 years 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 permalink fedilink source parent
[–] sabreW4K3@lazysoci.al 50 points 2 years ago (1 child) When you parse that code, it presents this ඞ symbol, which looks close enough to the famous characters from Among Us, the viral video game. permalink fedilink source parent hideshow 2 child comments replies: [–] DudeDudenson@lemmings.world 14 points 2 years ago (2 children) What is the simbol supposed to be originally? permalink fedilink source parent hideshow 4 child comments replies: [–] sabreW4K3@lazysoci.al 28 points 2 years ago (1 child) https://en.m.wiktionary.org/wiki/%E0%B6%9E permalink fedilink source parent hideshow 2 child comments replies: [–] degen@midwest.social 6 points 2 years ago Silly me, I thought it was gay permalink fedilink source parent [–] jameseb@lemm.ee 25 points 2 years ago That code point is U+0D9E SINHALA LETTER KANTAJA NAASIKYAYA. It's a letter in a writing system used in Sri Lanka. permalink fedilink source parent
[–] DudeDudenson@lemmings.world 14 points 2 years ago (2 children) What is the simbol supposed to be originally? permalink fedilink source parent hideshow 4 child comments replies: [–] sabreW4K3@lazysoci.al 28 points 2 years ago (1 child) https://en.m.wiktionary.org/wiki/%E0%B6%9E permalink fedilink source parent hideshow 2 child comments replies: [–] degen@midwest.social 6 points 2 years ago Silly me, I thought it was gay permalink fedilink source parent [–] jameseb@lemm.ee 25 points 2 years ago That code point is U+0D9E SINHALA LETTER KANTAJA NAASIKYAYA. It's a letter in a writing system used in Sri Lanka. permalink fedilink source parent
[–] sabreW4K3@lazysoci.al 28 points 2 years ago (1 child) https://en.m.wiktionary.org/wiki/%E0%B6%9E permalink fedilink source parent hideshow 2 child comments replies: [–] degen@midwest.social 6 points 2 years ago Silly me, I thought it was gay permalink fedilink source parent
[–] degen@midwest.social 6 points 2 years ago Silly me, I thought it was gay permalink fedilink source parent
[–] jameseb@lemm.ee 25 points 2 years ago That code point is U+0D9E SINHALA LETTER KANTAJA NAASIKYAYA. It's a letter in a writing system used in Sri Lanka. permalink fedilink source parent
[–] arudesalad@sh.itjust.works 9 points 2 years 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 permalink fedilink source parent