Skip to content

Instantly share code, notes, and snippets.

@MayankFawkes
Created October 29, 2019 08:24
Show Gist options
  • Select an option

  • Save MayankFawkes/1090ca3ccdbf0c404deb1b0a9bc5f566 to your computer and use it in GitHub Desktop.

Select an option

Save MayankFawkes/1090ca3ccdbf0c404deb1b0a9bc5f566 to your computer and use it in GitHub Desktop.
Run your code somewhere else.
code='''
import hashlib
result = hashlib.sha256(b"Password")
print("The byte equivalent of hash is : ", end ="")
print(result.hexdigest())
'''
import requests
from time import sleep
data={"lang":"python3","typed_code":str(code[1:-1].replace('"','\"').replace("'","\'")),"data_input":"[1, 2, 3]"}
url="https://leetcode.com/playground/api/runcode"
header={
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
}
r=requests.post(url,data=data,headers=header)
r=r.json()
url="https://leetcode.com/submissions/detail/{}/check/".format(r["interpret_id"])
while True:
r2=requests.get(url,headers=header)
if r2.status_code==200:
try:
if r2.json()["status_code"]:
for n in r2.json()["code_output"]:
print(n)
print("[Finished in {}]".format(r2.json()["status_runtime"]))
break
except:
print(end="")
else:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment