Skip to content

Instantly share code, notes, and snippets.

@smaspe
Last active January 12, 2016 22:03
Show Gist options
  • Save smaspe/b9945c26e2660c75432a to your computer and use it in GitHub Desktop.
Save smaspe/b9945c26e2660c75432a to your computer and use it in GitHub Desktop.
A code eval challenge solved some other way
# A side-step solution because I was too lazy to find the repeated word...
# It find the most common letter, but exclude ' ', which is the lowest value and is often more common than 'e'
import sys
from collections import Counter
with open(sys.argv[1], 'r') as test_cases:
for test in test_cases:
vals = map(int, test.split('|')[2].strip().split(' '))
m = min(vals)
e = Counter(v for v in vals if v != m).most_common(1)[0][0]
print ''.join(chr(i - e + ord('e')) for i in vals)
# Come to think of it, there is a good chance that ' ' is always here, and that this can therefore solved quite easily...
import sys
with open(sys.argv[1], 'r') as test_cases:
for test in test_cases:
vals = map(int, test.split('|')[2].strip().split(' '))
space = min(vals)
print ''.join(chr(i - space + ord(' ')) for i in vals)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment