Skip to content

Instantly share code, notes, and snippets.

@jackboot7
Created October 30, 2015 21:04
Show Gist options
  • Save jackboot7/2db132e99b6323804567 to your computer and use it in GitHub Desktop.
Save jackboot7/2db132e99b6323804567 to your computer and use it in GitHub Desktop.
[2015-10-19] Challenge #237 [Easy] Broken Keyboard
# -*- 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