Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2018
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. >>68762434
  2. fuck, forgot code
  3. [code]
  4. def day3():
  5. if not os.path.isfile(OUTPUT_FNAME):
  6. print("downloading " + INPUT_URL)
  7. opener = urllib.request.build_opener()
  8. opener.addheaders.append(('Cookie', 'session=' + COOKIE))
  9. k = opener.open(INPUT_URL)
  10. with open(OUTPUT_FNAME, "w") as f:
  11. f.write(k.read().decode("utf-8"))
  12.  
  13. with open(OUTPUT_FNAME) as f:
  14. lst = f.readlines()
  15. fug = {}
  16. ids = []
  17. things = []
  18. for ln in lst:
  19. #print(parseln(ln))
  20. p = parseln(ln)
  21. things.append(p)
  22. ids.append(p)
  23. for x in range(p['x'], p['x'] + p['width']):
  24. for y in range(p['y'], p['y'] + p['height']):
  25. idx =str(x) + "!!!" + str(y)
  26. if idx in fug:
  27. fug[idx].append(p)
  28. else:
  29. fug[idx] = [p]
  30.  
  31. print("at possibles")
  32. possibles = []
  33. for a in fug.keys():
  34. if len(fug[a]) == 1:
  35. possibles.append(fug[a][0])
  36.  
  37. def filterlist(ls, i):
  38. outa = []
  39. outb = []
  40. for n in ls:
  41. if n['id'] == i: outa.append(n)
  42. else: outb.append(n)
  43. return(outa, outb)
  44.  
  45. def dosearch(ls):
  46. i = ls[0]
  47. spl = [x for x in ls if x['id'] == i['id']]
  48. le = len(spl)
  49. w = i['width']
  50. h = i['height']
  51. print('id=' + str(i['id']) + ' w=' + str(w) + ' h=' + str(h) + ' len=' + str(le))
  52. if len(spl) == (i['width'] * i['height']):
  53. print(i)
  54. quit()
  55. else:
  56. dosearch([x for x in ls if x['id'] != i['id']])
  57. [/code]
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement