Refuse to submit example solutions
This commit is contained in:
parent
21246a92de
commit
f49eb930c0
1 changed files with 21 additions and 14 deletions
|
@ -39,8 +39,9 @@ DAY: int | None = None
|
|||
|
||||
def read_input(year: int, day: int, example: int | None = None) -> str:
|
||||
global YEAR, DAY
|
||||
YEAR = year
|
||||
DAY = day
|
||||
if example is None:
|
||||
YEAR = year
|
||||
DAY = day
|
||||
if example is None:
|
||||
f = Path(__file__).parent / f"../../.cache/{year}/{day}"
|
||||
else:
|
||||
|
@ -52,16 +53,22 @@ def ans(answer):
|
|||
print(answer)
|
||||
pyperclip.copy(str(answer))
|
||||
|
||||
submit_part = input("\nSubmit solution? level=")
|
||||
if submit_part in ["1", "2"] and YEAR is not None and DAY is not None:
|
||||
import bs4
|
||||
import requests
|
||||
if YEAR is None or DAY is None:
|
||||
print("\n(cannot submit solution of example)")
|
||||
return
|
||||
|
||||
session = (Path(__file__).parent / f"../../.cache/session").read_text()
|
||||
resp = requests.post(
|
||||
f"https://adventofcode.com/{YEAR}/day/{DAY}/answer",
|
||||
cookies={"session": session},
|
||||
data={"level": submit_part, "answer": answer},
|
||||
).text
|
||||
bs = bs4.BeautifulSoup(resp, "html.parser")
|
||||
print(bs.main.article.p.text)
|
||||
submit_part = input("\nSubmit solution? level=")
|
||||
if submit_part not in ["1", "2"]:
|
||||
return
|
||||
|
||||
import bs4
|
||||
import requests
|
||||
|
||||
session = (Path(__file__).parent / f"../../.cache/session").read_text()
|
||||
resp = requests.post(
|
||||
f"https://adventofcode.com/{YEAR}/day/{DAY}/answer",
|
||||
cookies={"session": session},
|
||||
data={"level": submit_part, "answer": answer},
|
||||
).text
|
||||
bs = bs4.BeautifulSoup(resp, "html.parser")
|
||||
print(bs.main.article.p.text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue