Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Neys'
- from math import floor
- def splitInteger(num,parts):
- splits = []
- count = parts
- if num % parts == 0:
- splits = [int(num/parts) for x in range(parts)]
- print(splits)
- else:
- while len(splits) < count:
- splits.append( int(round(num/parts)) )
- num -= 0.5
- if num % parts == 0:
- parts -= 1
- while len(splits) < count:
- splits.append( int(round(num/parts)) )
- #print(num)
- print(splits)
- def splitIntegerFuck(num,parts): print( [num/parts]*(parts-num%parts)+[num/parts+1]*(num%parts) )
- splitIntegerFuck(20,6)
- splitIntegerFuck(10,1)
- splitIntegerFuck(2, 2)
- splitIntegerFuck(11,3)
- splitIntegerFuck(20, 5)
- splitInteger(99,2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement