Guest User

Untitled

a guest
Feb 11th, 2012
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # for http://www.reddit.com/r/dailyprogrammer/comments/pkwgf/2112012_challenge_3_difficult/
  5.  
  6. words = open('../wordlist.txt').readlines()
  7. scrambled = {'mkeart': '', 'sleewa': '', 'edcudls': '', 'iragoge': '', 'usrlsle': '', 'nalraoci': '', 'nsdeuto': '', 'amrhat': '', 'inknsy': '', 'iferkna': ''}
  8.  
  9. for s in scrambled.keys():
  10.     s_sorted = "".join(sorted(i for i in s))
  11.     for word in words:
  12.         w = word.strip()
  13.         if s_sorted == "".join(sorted(i for i in w)):
  14.             scrambled[s] = w
  15.  
  16. # sort by key length
  17. for s in sorted(scrambled.keys(), key=lambda k: len(k)):
  18.     print('%s: %s' % (s, scrambled[s]))
Add Comment
Please, Sign In to add comment