From 2f83962f1799e94c8108c575d1c0d35868b06c4e Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Thu, 8 Apr 2021 15:00:33 +0200 Subject: Pracownia 4 aisd --- Semestr 4/aisd/pracownia2/gen.py | 24 ++++++++++++++++++++++++ Semestr 4/aisd/pracownia2/gen_test.sh | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Semestr 4/aisd/pracownia2/gen.py create mode 100755 Semestr 4/aisd/pracownia2/gen_test.sh (limited to 'Semestr 4/aisd/pracownia2') diff --git a/Semestr 4/aisd/pracownia2/gen.py b/Semestr 4/aisd/pracownia2/gen.py new file mode 100644 index 0000000..13aed55 --- /dev/null +++ b/Semestr 4/aisd/pracownia2/gen.py @@ -0,0 +1,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() diff --git a/Semestr 4/aisd/pracownia2/gen_test.sh b/Semestr 4/aisd/pracownia2/gen_test.sh new file mode 100755 index 0000000..d5bff05 --- /dev/null +++ b/Semestr 4/aisd/pracownia2/gen_test.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +mkdir -p tests +cp gen.py tests/ +cd tests + +python3 gen.py 1 5 20 > t1.in +python3 gen.py 2 10 100 > t2.in +python3 gen.py 3 20 200 > t3.in +python3 gen.py 4 40 600 > t4.in +python3 gen.py 5 80 5000 > t5.in +python3 gen.py 6 160 10000 > t6.in +python3 gen.py 7 320 10000 > t7.in +python3 gen.py 8 640 20000 > t8.in +python3 gen.py 9 1280 20000 > t9.in +python3 gen.py 10 2000 2000 > t10.in +python3 gen.py 11 2000 20000 > t11.in +python3 gen.py 12 2000 200000 > t12.in +python3 gen.py 13 2000 1000000 > t13.in +python3 gen.py 14 2000 1000000 > t14.in +python3 gen.py 15 2000 1000000 > t15.in + + +rm gen.py -- cgit v1.2.3