-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterview_test.py
More file actions
52 lines (41 loc) · 1.15 KB
/
interview_test.py
File metadata and controls
52 lines (41 loc) · 1.15 KB
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
import requests
import json
apiEndpoint = 'http://interview-black-box:5000'
print('Print the rules and help text')
recieve = requests.get(url=apiEndpoint)
print(recieve.text)
print('-----------------------------------------------')
print('Starting interview test Python program')
print('Start the initial query to generate sequence')
recieve = requests.get(url=f"{apiEndpoint}/start")
print(recieve.text)
print('Parse the query data')
data = json.loads(recieve.text)
print('Setup the variables')
L = data['sequenceLength']
a_n = data['first']
a_n_plus_1 = data['second']
print('Generate numbers in a sequence of the requested length')
for i in range(L):
if i % 3 == 0:
a_n_plus_2 = 0
elif i % 3 == 1:
a_n_plus_2 = 0
else:
a_n_plus_2 = 0
# Update numbers next in sequence
print(i, a_n, a_n_plus_1, a_n_plus_2)
a_n = a_n_plus_1
a_n_plus_1 = a_n_plus_2
print('Submit the solution')
postData = {
"id": data['id'],
"solution": a_n_plus_2
}
print(postData)
print('Get the submission status')
recieve = requests.post(
url=f"{apiEndpoint}/solution",
data=json.dumps(postData)
)
print(str(recieve.text))