Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # for http://www.reddit.com/r/dailyprogrammer/comments/pkwgf/2112012_challenge_3_difficult/
- words = open('../wordlist.txt').readlines()
- scrambled = {'mkeart': '', 'sleewa': '', 'edcudls': '', 'iragoge': '', 'usrlsle': '', 'nalraoci': '', 'nsdeuto': '', 'amrhat': '', 'inknsy': '', 'iferkna': ''}
- for s in scrambled.keys():
- s_sorted = "".join(sorted(i for i in s))
- for word in words:
- w = word.strip()
- if s_sorted == "".join(sorted(i for i in w)):
- scrambled[s] = w
- # sort by key length
- for s in sorted(scrambled.keys(), key=lambda k: len(k)):
- print('%s: %s' % (s, scrambled[s]))
Add Comment
Please, Sign In to add comment