2023-12-01 13:35:13 +01:00
|
|
|
from autokattis import Kattis
|
|
|
|
import argparse
|
|
|
|
from os import system
|
|
|
|
from requests import get
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
def prepare_problem(problem):
|
|
|
|
system('firefox ' + problem['link'])
|
|
|
|
name = " "
|
|
|
|
try:
|
|
|
|
name = problem['pid']
|
|
|
|
except:
|
|
|
|
name = problem['name']
|
|
|
|
|
|
|
|
# system('mkdir problems/' + datetime.now.strftime("%d_%m_%y") + "/" name)
|
|
|
|
|
|
|
|
# TODO: Add inputs
|
|
|
|
r = get(problem['link'])
|
|
|
|
# tables = soup.find_all('table')
|
|
|
|
# soup = BeautifulSoup(r.text, 'html.parser')
|
|
|
|
# for table in tables:
|
|
|
|
# with open("problems/" + problem['pid'] + "/"+ str(count) + ".in", "w") as f:
|
|
|
|
# f.write(table[0].text)
|
|
|
|
# print(table.text)
|
|
|
|
|
|
|
|
def find_user(ranklist:dict) -> int:
|
|
|
|
for i in ranklist:
|
|
|
|
if i['username'] == 'confestim':
|
|
|
|
return i['rank']
|
|
|
|
return -1
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Kattis submission tool')
|
|
|
|
parser.add_argument('-p', metavar='problem', type=str, help='problem name')
|
|
|
|
parser.add_argument('-pl', action='store_true', default=False, help='plot problem')
|
|
|
|
parser.add_argument('-s', action='store_true', default=False, help='suggest problem')
|
|
|
|
parser.add_argument('-r', action='store_true', default=False, help='Show ranklist')
|
|
|
|
parser.add_argument('-u', action="store_true", default=False, help="ShowStarted, but Unsolved")
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2023-12-01 13:39:42 +01:00
|
|
|
kt = Kattis('confestim', 'bobit0drog@231', )
|
2023-12-01 13:35:13 +01:00
|
|
|
problem = args.p
|
|
|
|
plot = args.pl
|
|
|
|
suggest = args.s
|
|
|
|
unsolved = args.u
|
|
|
|
|
|
|
|
if args.r:
|
|
|
|
uni = find_user(kt.ranklist(university='University of Groningen'))
|
|
|
|
country = find_user(kt.ranklist(country='Bulgaria'))
|
|
|
|
print("🎓:" + str(uni) + ", 🤻 :" + str(country))
|
|
|
|
if plot:
|
|
|
|
print(kt.plot_problems(show_partial=False))
|
|
|
|
|
|
|
|
if suggest:
|
|
|
|
for i in kt.suggest():
|
|
|
|
prepare_problem(i)
|
|
|
|
|
|
|
|
def stars(problem):
|
|
|
|
return problem["difficulty"]
|
|
|
|
|
|
|
|
if unsolved:
|
|
|
|
problems = kt.problems(show_solved=False, show_tried=True)
|
|
|
|
problems.sort(key=stars)
|
|
|
|
print(str(len(problems)) + " problems unsolved.")
|
|
|
|
for problem in problems:
|
|
|
|
print(f"✱ {problem['name']} {problem['difficulty']}✪")
|
|
|
|
yn = input("Do you want to open them in browser?(Y/n)")
|
|
|
|
if (yn == 'n' or yn == 'N'):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
for problem in problems:
|
|
|
|
prepare_problem(problem)
|
|
|
|
|
|
|
|
elif problem:
|
|
|
|
print(kt.problem(problem))
|