PY
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
def shuffle(arr, cup, exchange):
print ("initial stage",arr,"\ncup no",cup,"\nshuffle array is",exchange)
p=1
if cup in arr:
for i in exchange :
if i in arr: p=0
if p==0:
l=len(arr)
for i in exchange :
arr[i-1],arr[l-i]=arr[l-i],arr[i-1]
print (arr)
for i in range(l):
if arr[i]==cup :
print ("cup no",cup,"at location",i+1,"\n\n")
return None
else : print ("wrong input");return None
shuffle ([1,2], 1, [1,2,2,2,1])
shuffle ([1,2,3], 2, [1,3])
shuffle ([1,2,3,4,5], 4, [3,1,4,5,2])
shuffle ([1,2,3],5,[3,1,2])
##:author-->> Sayan Chandra
## TEST CASES
'''
[ 1, 2 ] | 1 | [ 1, 2, 2, 2, 1 ]
"Cup no. 1 at position 2."
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run