Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.83 KB | None | 0 0
  1. # from dust i have come, dust i will be
  2.  
  3. import urllib.request
  4. import json
  5.  
  6.  you = input("what is your cf handle?\n")
  7.  other = input("what is the handle of the user you want to follow?\n")
  8.  
  9.  
  10. # from the first submission to 5k th submission
  11. # number of total submission is unknown, therefore we take 5k
  12.  
  13. # =============================================================================
  14. url = "https://codeforces.com/api/user.status?handle=" + you + "&from=1&count=5000"
  15. res = urllib.request.urlopen(url)
  16. res_body = res.read()
  17. j = json.loads(res_body.decode("utf-8"))
  18.  
  19. X = set()
  20. m1 = 0
  21. for subs in j["result"]:
  22.     if subs["verdict"] == "OK":
  23.         temp = subs["problem"]
  24.         try:
  25.             s = str(temp["contestId"]) + temp["index"] + ". " + temp["name"]
  26.             X.add(s)
  27.         except:
  28.             m1 += 1
  29.  
  30. # =============================================================================
  31.  
  32.  
  33. # =============================================================================
  34. url = "https://codeforces.com/api/user.status?handle=" + other + "&from=1&count=5000"
  35. res = urllib.request.urlopen(url)
  36. res_body = res.read()
  37. j = json.loads(res_body.decode("utf-8"))
  38.  
  39. Y = set()
  40. m2 = 0
  41. for subs in j["result"]:
  42.     if subs["verdict"] == "OK":
  43.         temp = subs["problem"]
  44.         try:
  45.             s = str(temp["contestId"]) + temp["index"] + ". " + temp["name"]
  46.             Y.add(s)
  47.         except:
  48.             m2 += 1
  49.  
  50. cnt = 0
  51. f = open("output.txt", "w")
  52. for key in Y:
  53.     if key not in X:
  54.         f.write(key + "\n")
  55.         cnt += 1
  56.  
  57. # =============================================================================
  58.  
  59. '''
  60. you may want to solve those problems that an user have solved but
  61. you haven't. just enter your handle, handle of that user, and this code will generate
  62. a txt file with the list of the problems
  63. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement