Skip to main content
Shorter code
Source Link
Logic Knight
  • 6.8k
  • 1
  • 18
  • 50

Python 2, 92 54 bytes

print'K{7j)yE<}'.find(chr(hash(raw_input())%95+32))+1

The index string is created with for word in words: print chr(hash(word)%95+32),. As pointed out in Jakube's answer, the hash function will give different results depending on Python version. This index string is computed on 64 bit Python 2.7.6.

Longer (92 bytes) but less cryptic answer:

print'though through thorough Thoreau throw threw trough tough troll'.find(raw_input())/7+1

The programs returns 1-9 for though through thorough Thoreau throw threw trough tough troll in that order. When the input is not found, find will return a -1 which conveniently turns into a zero after the +1.

Python 2, 92 54 bytes

print'K{7j)yE<}'.find(chr(hash(raw_input())%95+32))+1

The index string is created with for word in words: print chr(hash(word)%95+32),

Longer (92 bytes) but less cryptic answer:

print'though through thorough Thoreau throw threw trough tough troll'.find(raw_input())/7+1

The programs returns 1-9 for though through thorough Thoreau throw threw trough tough troll in that order. When the input is not found, find will return a -1 which conveniently turns into a zero after the +1.

Python 2, 92 54 bytes

print'K{7j)yE<}'.find(chr(hash(raw_input())%95+32))+1

The index string is created with for word in words: print chr(hash(word)%95+32),. As pointed out in Jakube's answer, the hash function will give different results depending on Python version. This index string is computed on 64 bit Python 2.7.6.

Longer (92 bytes) but less cryptic answer:

print'though through thorough Thoreau throw threw trough tough troll'.find(raw_input())/7+1

The programs returns 1-9 for though through thorough Thoreau throw threw trough tough troll in that order. When the input is not found, find will return a -1 which conveniently turns into a zero after the +1.

Shorter code
Source Link
Logic Knight
  • 6.8k
  • 1
  • 18
  • 50

Python 2, 9292 54 bytes

print'K{7j)yE<}'.find(chr(hash(raw_input())%95+32))+1

The index string is created with for word in words: print chr(hash(word)%95+32),

Longer (92 bytes) but less cryptic answer:

print'though through thorough Thoreau throw threw trough tough troll'.find(raw_input())/7+1

The programprograms returns 1-9 to though through thorough Thoreau throw threw trough tough trollfor though through thorough Thoreau throw threw trough tough troll in that order. When the input is not found, find will return a -1 which conveniently turns in to the neededinto a zero after the +1.

Python 2, 92 bytes

print'though through thorough Thoreau throw threw trough tough troll'.find(raw_input())/7+1

The program returns 1-9 to though through thorough Thoreau throw threw trough tough troll in that order. When the input is not found, find will return a -1 which conveniently turns in to the needed zero after the +1.

Python 2, 92 54 bytes

print'K{7j)yE<}'.find(chr(hash(raw_input())%95+32))+1

The index string is created with for word in words: print chr(hash(word)%95+32),

Longer (92 bytes) but less cryptic answer:

print'though through thorough Thoreau throw threw trough tough troll'.find(raw_input())/7+1

The programs returns 1-9 for though through thorough Thoreau throw threw trough tough troll in that order. When the input is not found, find will return a -1 which conveniently turns into a zero after the +1.

Source Link
Logic Knight
  • 6.8k
  • 1
  • 18
  • 50

Python 2, 92 bytes

print'though through thorough Thoreau throw threw trough tough troll'.find(raw_input())/7+1

The program returns 1-9 to though through thorough Thoreau throw threw trough tough troll in that order. When the input is not found, find will return a -1 which conveniently turns in to the needed zero after the +1.