Skip to content

Instantly share code, notes, and snippets.

@yuheiomori
Created May 11, 2012 23:57
Show Gist options
  • Save yuheiomori/2663187 to your computer and use it in GitHub Desktop.
Save yuheiomori/2663187 to your computer and use it in GitHub Desktop.
CodeEval Self Describing Numbers
import sys
def is_self_describing_numbers(s):
if all([s.count(str(idx)) == int(num) for idx, num in enumerate(s)]):
return 1
else:
return 0
if __name__ == '__main__':
test_cases = open(sys.argv[1], 'r')
for line in test_cases:
print is_self_describing_numbers(line.rstrip())
test_cases.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment