Advertisement
Sax

Tercer Avance WordZap

Sax
Apr 23rd, 2012
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. import random
  2.  
  3. #Make Alphabet -----------------------------------------------------
  4. lulz = "abcdefghijklmnopqrstuvwxyz"
  5. letters = list(lulz)
  6.  
  7. its = [15,6,5,7,15,4,6,9,15,2,5,5,8,13,11,2,0,10,11,5,10,2,6,4,2,2]
  8.  
  9. zipo = zip(letters,its)
  10.  
  11. dictionary = dict(zipo)
  12.  
  13. def fill(letter,its):
  14.     for i in range(its):
  15.         letters.append(letter)
  16.  
  17. for (x,y) in zipo:
  18.     fill(x,y)
  19.  
  20. random.shuffle(letters)
  21.  
  22. #Choose Letters -----------------------------------------------------
  23.  
  24. def randomize():
  25.     chosen = random.sample(letters,9)
  26.     return chosen
  27.  
  28. chosen = randomize()
  29.  
  30.  
  31. #Sort Alphabetically ------------------------------------------------
  32.  
  33. ordered = sorted(chosen)
  34.  
  35. #Mostrar valores de cada letra en orden
  36. values = []
  37.  
  38. for i in ordered:
  39.     if i in dictionary:
  40.         values.append(dictionary.get(i))
  41.  
  42. zipo2 = zip(ordered,values)
  43.  
  44. def compare(x,y):
  45.     key_of_x=x[1]
  46.     key_of_y=y[1]
  47.     if key_of_x > key_of_y:
  48.         return -1
  49.     elif key_of_x < key_of_y:
  50.         return 1
  51.     else:
  52.         return 0
  53.  
  54. order_by_value = sorted(zipo2,cmp=compare)
  55.  
  56. #Selecciona los 3 mayores
  57.  
  58. search_terms = []
  59.  
  60. for i in range(3):
  61.     search_terms.append(order_by_value[i][0])
  62.  
  63. searchTerm = search_terms[0] +search_terms[1] +search_terms[2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement