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?