-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_problem.py
44 lines (38 loc) · 878 Bytes
/
game_problem.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
"""
Problem Link = https://www.hackerrank.com/challenges/an-interesting-game-1/problem
"""
def gamingArray_optimized(arr):
count=0
m=0
for i in arr:
if i>m:
m=i
count+=1
if count%2==0:
print("ANDY")
else:
print("BOB")
def gamingArray(arr): ### time exceeding for 4 cases , optimizationx please
c = -1
while(1):
if len(arr) == 0:
break
i = arr.index(max(arr))
del arr[i:]
c +=1
if c % 2==0:
print("BOB")
else:
print("ANDY")
t =[7 ,4 ,6 ,5 ,9] ## ANDY
s = [1, 3, 5, 7, 9] ## BOB
e = [5 ,2 ,6 ,3 ,4] ## ANDY
d = [3,1] ## BOB
gamingArray(t)
gamingArray(s)
gamingArray(e)
gamingArray(d)
gamingArray_optimized(t)
gamingArray_optimized(s)
gamingArray_optimized(e)
gamingArray_optimized(d)