Created
October 30, 2015 21:04
-
-
Save jackboot7/2db132e99b6323804567 to your computer and use it in GitHub Desktop.
[2015-10-19] Challenge #237 [Easy] Broken Keyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
# [2015-10-19] Challenge #237 [Easy] Broken Keyboard | |
# https://www.reddit.com/r/dailyprogrammer/comments/3pcb3i/20151019_challenge_237_easy_broken_keyboard/ | |
def return_word(s, words): | |
s = set(s) | |
result = '' | |
for word in words: | |
if s.issuperset(word): | |
if len(word) > len(result): | |
result = word | |
return result | |
if __name__ == "__main__": | |
with open('/usr/share/dict/words') as f: | |
words = f.read().split() | |
n = int(raw_input()) | |
for i in xrange(n): | |
s = raw_input() | |
print "{0} = {1}".format(s, return_word(s, words)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment