-
Notifications
You must be signed in to change notification settings - Fork 0
/
leetcode_check.py
77 lines (68 loc) · 2.02 KB
/
leetcode_check.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import RPi.GPIO as GPIO
import requests
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(2, GPIO.OUT)
GPIO.setup(3, GPIO.OUT)
GPIO.setup(4, GPIO.OUT)
api_code_url = "https://alfa-leetcode-api.onrender.com/daily"
api_submission_check_url = "https://alfa-leetcode-api.onrender.com/maitysourab/acSubmission?limit=1"
headers = {
"Content-Type": "application/json"
}
def red_color():
GPIO.setup(2, GPIO.LOW)
GPIO.setup(3, GPIO.LOW)
GPIO.setup(4, GPIO.LOW)
time.sleep(1)
print("Red")
GPIO.setup(2, GPIO.HIGH)
GPIO.setup(3, GPIO.HIGH)
GPIO.setup(4, GPIO.HIGH)
def green_color():
GPIO.setup(2, GPIO.LOW)
GPIO.setup(3, GPIO.LOW)
GPIO.setup(4, GPIO.LOW)
time.sleep(1)
print("Green")
#GPIO.setup(3, GPIO.HIGH)
#GPIO.setup(4, GPIO.HIGH)
GPIO.setup(2, GPIO.HIGH)
def blue_color():
GPIO.setup(2, GPIO.LOW)
GPIO.setup(3, GPIO.LOW)
GPIO.setup(4, GPIO.LOW)
time.sleep(1)
print("Blue")
GPIO.setup(4, GPIO.HIGH)
GPIO.setup(2, GPIO.HIGH)
response = requests.get(api_code_url, headers=headers)
if response.status_code == 200:
# Parse the JSON response
daily_challenge = response.json()
daily_challenge_code_title = daily_challenge["questionTitle"]
else:
print(
f"Failed to retrieve daily challenge. Status code: {response.status_code}")
print(response.text)
blue_color()
print(daily_challenge_code_title)
while True:
response = requests.get(api_submission_check_url, headers=headers)
if response.status_code == 200:
# Parse the JSON response
all_submission = response.json()
last_submission = all_submission["submission"][0]["title"]
if last_submission == daily_challenge_code_title:
green_color()
print("today task complete")
break
else:
red_color()
else:
print(
f"Failed to retrieve daily challenge. Status code: {response.status_code}")
print(response.text)
blue_color()
time.sleep(60)