Skip to main content
17 of 17
Commonmark migration

Python 2,  20 21 33 39 45  50 bytes

Now very much a collaborative effort!

+2 thanks to Aidan F. Pierce (replace sorted({0}) with map(long,{0}))

+8 thanks to dylnan (use of \ and newline to replace space; suggestions to move from 0 to a mathematical expression; replacing -1 with -True; use of hexadecimal)

+11 thanks to Angs (4*23+~91 -> ~4836+9*1075/2 then later ~197836254+0xbCABdDF -> ~875+0xDEAdFBCbc%1439/2*6)


if\ map(long,{~875+0xDEAdFBCbc%1439/2*6})[-True]:q 

Try it online! Or see the confirmation suite

0xDEAdFBCbc is hexadecimal and evaluates to 59775106236.
~ is bit-wise complement so ~875 evaluates to -876.
% is the modulo operator so 0xDEAdFBCbc%1439 evaluates to 293.
/ is integer division so 0xDEAdFBCbc%1439/2 evaluates to 146.
* is multiplication so xDEAdFBCbc%1439/2*6 evaluates to 876.
+ is addition so ~875+xDEAdFBCbc%1439/2*6 evaluates to 0.
...no stripped version also evaluates to 0.

{0} is a set containing a single element, 0.

Calling sorted with a set as the argument yields a list, which may be indexed into with [...].

Without sorted the code ({0}) would just yield the set and this cannot be indexed into in the same fashion, if({0})[-True]:q would raise a TypeError.

Indexing in Python is 0-based and allows negative indexing from the back and True is equivalent to 1, hence sorted({0})[-True] finds the element 0, while sorted({0})[True] will raise an IndexError, as will sorted({})[-True] and sorted({0})[] is invalid syntax.

The 0 that is found is falsey so the body of the if, q, is never executed, however if it were it would raise a NameError since q has not been defined.

Since a non-empty list is truthy we cannot trim down to if[-1]:q either.

See the confirmation suite to see: confirmation the bytes being unique; all the errors; and the success of the code itself.

Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293