aboutsummaryrefslogtreecommitdiff
path: root/semestr-4/aisd/pracownia2/gen.py
blob: 13aed5567159bc08efffd1cb5ad261b17704c50d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from random import randint, seed
import sys

if (len(sys.argv) < 4):
    print("usage: python3 gen.py seed n sum")
    exit()

seed(sys.argv[1])

n, sum = map(int, sys.argv[2:4])
if n > sum:
    print("N musi być mniejsze równe od sum.")
    exit()

t = [1 for i in range(n)]

for i in range(sum - n):
    idx = randint(0, n - 1)
    t[idx] += 1

print(n)
for i in t:
    print(i, end=' ')
print()