-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicprogramming2.py
50 lines (40 loc) · 991 Bytes
/
basicprogramming2.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
import statistics
N, t = map(int, input().split())
myDict = {}
A = [int(x) for x in input().split()]
if t == 1:
doesExist = False
for i in range(len(A)):
for j in range(i + 1, len(A)):
if A[i] != A[j] and A[i] + A[j] == 7777:
doesExist = True
break
if doesExist:
print('Yes')
else:
print("No")
elif t == 2:
if len(A) == len(set(A)):
print("Unique")
else:
print("Contains duplicate")
elif t == 3:
for integer in A:
myDict[integer] = myDict.get(integer, 0) + 1
for key, value in myDict.items():
if value > N/2:
print(key)
break
else:
print(-1)
elif t == 4:
if N % 2 != 0:
print(statistics.median(A))
else:
A.sort()
print(A[int(len(A)/2) - 1], A[int(len(A)/2)])
elif t == 5:
A.sort()
for num in A:
if num >= 100 and num <= 999:
print(num, end=' ')