-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontest.py
33 lines (26 loc) · 884 Bytes
/
contest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# In the name of ALLAH
# Author : Raashid Anwar
import json
import requests
import os
import subprocess
while True:
print("Contest Id : ", end = "")
contestId = input()
res = requests.get('https://codeforces.com/api/contest.standings?contestId=' + contestId + '&from=1&count=5&showUnofficial=true')
if str(res) == '<Response [200]>':
path = os.getcwd()
os.mkdir(str(path) + '/CF/' + str(contestId))
os.chdir(str(path) + '/CF/' + str(contestId))
break
else:
print("Invalid Contest Id")
for data in res.json()['result']['problems']:
with open(str(data['index']) + '.cpp', 'w') as files:
for line in open(str(os.getenv("HOME"))+ '/template.cpp', 'r'):
files.write(line)
files.close()
subprocess.Popen(['gedit', data['index'] + '.cpp'])
print(data['index'] + '.cpp file is Created!')
os.system("pwd")
#os.system("/bin/bash")