Skip to content

Commit

Permalink
Solved Cut the Sticks
Browse files Browse the repository at this point in the history
  • Loading branch information
letitz committed Sep 27, 2014
1 parent 96a79e1 commit 6c37293
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cut_the_sticks/cut_the_sticks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/python3

# https://www.hackerrank.com/challenges/cut-the-sticks

import sys

def print_cuts(N, lengths):
max_length = 0
sticks = [ 0 ] * 1000
for length in lengths:
sticks[length] += 1
max_length = max(max_length,length)

for length in range(max_length + 1):
if sticks[length] > 0:
print(N)
N -= sticks[length]

def main():
N = int(sys.stdin.readline())
lengths = [ int(x) for x in sys.stdin.readline().split() ]
print_cuts(N,lengths)

if __name__ == '__main__':
main()

0 comments on commit 6c37293

Please sign in to comment.