Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

The main motivation for my question is hash functions. Let's take an example challenge (although here's a real challengehere's a real challenge):

Print 42 if the input is "the answer to life the universe and everything", 0 otherwise.

You might program this like this in Python 2:

print(42if raw_input()=="the answer to life the universe and everything"else 0)

You could also solve it like this:

from hashlib import*
print(42if sha1(raw_input()).hexdigest()=="2adc3e9a2bfb6b4ae5285b11dacc3990bb075585"else 0)

In this case it's not any shorter, but the idea is there.

Is this allowed? It's cryptographically impossible to find an input that fails, but theoretically there are inputs for which the program exhibits wrong behavior.

If this is allowed, how hard must it be to find an incorrect input before allowing it?

The main motivation for my question is hash functions. Let's take an example challenge (although here's a real challenge):

Print 42 if the input is "the answer to life the universe and everything", 0 otherwise.

You might program this like this in Python 2:

print(42if raw_input()=="the answer to life the universe and everything"else 0)

You could also solve it like this:

from hashlib import*
print(42if sha1(raw_input()).hexdigest()=="2adc3e9a2bfb6b4ae5285b11dacc3990bb075585"else 0)

In this case it's not any shorter, but the idea is there.

Is this allowed? It's cryptographically impossible to find an input that fails, but theoretically there are inputs for which the program exhibits wrong behavior.

If this is allowed, how hard must it be to find an incorrect input before allowing it?

The main motivation for my question is hash functions. Let's take an example challenge (although here's a real challenge):

Print 42 if the input is "the answer to life the universe and everything", 0 otherwise.

You might program this like this in Python 2:

print(42if raw_input()=="the answer to life the universe and everything"else 0)

You could also solve it like this:

from hashlib import*
print(42if sha1(raw_input()).hexdigest()=="2adc3e9a2bfb6b4ae5285b11dacc3990bb075585"else 0)

In this case it's not any shorter, but the idea is there.

Is this allowed? It's cryptographically impossible to find an input that fails, but theoretically there are inputs for which the program exhibits wrong behavior.

If this is allowed, how hard must it be to find an incorrect input before allowing it?

Tweeted twitter.com/StackCodeGolf/status/699096603450306560
edited title
Link
orlp
  • 39.2k
  • 19
  • 33

Are incorrect, but impossibly to showtheoretically incorrect answers allowed if it's (near) impossible to find incorrect inputs?

Source Link
orlp
  • 39.2k
  • 19
  • 33

Are incorrect, but impossibly to show incorrect answers allowed?

The main motivation for my question is hash functions. Let's take an example challenge (although here's a real challenge):

Print 42 if the input is "the answer to life the universe and everything", 0 otherwise.

You might program this like this in Python 2:

print(42if raw_input()=="the answer to life the universe and everything"else 0)

You could also solve it like this:

from hashlib import*
print(42if sha1(raw_input()).hexdigest()=="2adc3e9a2bfb6b4ae5285b11dacc3990bb075585"else 0)

In this case it's not any shorter, but the idea is there.

Is this allowed? It's cryptographically impossible to find an input that fails, but theoretically there are inputs for which the program exhibits wrong behavior.

If this is allowed, how hard must it be to find an incorrect input before allowing it?