-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode21.py
More file actions
41 lines (32 loc) · 782 Bytes
/
Copy pathcode21.py
File metadata and controls
41 lines (32 loc) · 782 Bytes
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
#cut the sticks
#link : https://www.hackerrank.com/challenges/cut-the-sticks/problem
import math
import os
import random
import re
import sys
# Complete the cutTheSticks function below.
def cutTheSticks(arr):
a=[]
n=len(arr)
x=min(arr)
i=arr.count(x)
while i!=n:
a.append(n)
while i>0:
arr.remove(x)
i-=1
x=min(arr)
i=arr.count(x)
n=len(arr)
if n!=0:
a.append(n)
return a
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
arr = list(map(int, input().rstrip().split()))
result = cutTheSticks(arr)
fptr.write('\n'.join(map(str, result)))
fptr.write('\n')
fptr.close()