Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Python, 13 bytes

[(0,0)].count

Try it online! Takes input as a tuple.

Using an object method object method for the function avoids the boilerplate of a lambda.

lambda a,b:a-~b # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.

If one could output a Boolean here, which I find shady, a byte could be saved as

(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:

[(0,0)].pop

If string I/O is allowed and leading zeroes are OK, there's the 8-byte solution

'1'.join

This concatenates a1b, which is always bigger than a+b.

Python, 13 bytes

[(0,0)].count

Try it online! Takes input as a tuple.

Using an object method for the function avoids the boilerplate of a lambda.

lambda a,b:a-~b # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.

If one could output a Boolean here, which I find shady, a byte could be saved as

(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:

[(0,0)].pop

If string I/O is allowed and leading zeroes are OK, there's the 8-byte solution

'1'.join

This concatenates a1b, which is always bigger than a+b.

Python, 13 bytes

[(0,0)].count

Try it online! Takes input as a tuple.

Using an object method for the function avoids the boilerplate of a lambda.

lambda a,b:a-~b # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.

If one could output a Boolean here, which I find shady, a byte could be saved as

(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:

[(0,0)].pop

If string I/O is allowed and leading zeroes are OK, there's the 8-byte solution

'1'.join

This concatenates a1b, which is always bigger than a+b.

deleted 13 characters in body
Source Link
xnor
  • 149.6k
  • 26
  • 287
  • 676

Python, 13 bytes

[(0,0)].count

Try it online! Takes input as a tuple.

Using an object method for the function avoids the boilerplate of a lambda.

lambda a,b:a-~b # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.

If one could output a Boolean here, which I find shady, a byte could be saved as

(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:

[(0,0)].pop

If string I looked for a binary arithmetical operator that avoid division, but it seems there/O is none. a*b, a<<b, a|b, a&ballowed and leading zeroes are OK, there's the 8-byte solution

'1'.join

This concatenates a^ba1b, and a**b all have collisions withwhich is always bigger than a+b.

Python, 13 bytes

[(0,0)].count

Try it online! Takes input as a tuple.

Using an object method for the function avoids the boilerplate of a lambda.

lambda a,b:a-~b # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.

If one could output a Boolean here, which I find shady, a byte could be saved as

(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:

[(0,0)].pop

I looked for a binary arithmetical operator that avoid division, but it seems there is none. a*b, a<<b, a|b, a&b, a^b, and a**b all have collisions with a+b.

Python, 13 bytes

[(0,0)].count

Try it online! Takes input as a tuple.

Using an object method for the function avoids the boilerplate of a lambda.

lambda a,b:a-~b # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.

If one could output a Boolean here, which I find shady, a byte could be saved as

(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:

[(0,0)].pop

If string I/O is allowed and leading zeroes are OK, there's the 8-byte solution

'1'.join

This concatenates a1b, which is always bigger than a+b.

Source Link
xnor
  • 149.6k
  • 26
  • 287
  • 676

Python, 13 bytes

[(0,0)].count

Try it online! Takes input as a tuple.

Using an object method for the function avoids the boilerplate of a lambda.

lambda a,b:a-~b # 15 bytes

Here, the idea is to map (0,0) to 1 and everything else to 0. Since only 0+0 gives a sum of 0 among natural numbers, that always avoids matching the sum.

If one could output a Boolean here, which I find shady, a byte could be saved as

(0,0).__ge__

This checks if the input tuple is at most (0,0), which is only true for (0,0). In Python, True==1 and False==0. Even more shadily, outputting via exit code and treating that as a Python Boolen would save two bytes:

[(0,0)].pop

I looked for a binary arithmetical operator that avoid division, but it seems there is none. a*b, a<<b, a|b, a&b, a^b, and a**b all have collisions with a+b.

AltStyle によって変換されたページ (->オリジナル) /