PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def shuffle(cup, f, shuf):
if f not in cup:
print("Cup not found!")
return
for i in shuf:
try:
d = cup.index(i)
except ValueError:
continue
cup[d], cup[-d-1] = cup[-d-1], i
print("Cup no.",f,"at pos.",cup.index(f)+1)
shuffle([1, 2], 1, [1, 2, 2, 2, 1])
shuffle([1, 2, 3], 2, [1, 3])
shuffle([1, 2, 3, 4, 5], 4, [6, 1, 4, 5, 2])
# https://www.sololearn.com/Discuss/853905/?ref=app
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run