aboutsummaryrefslogtreecommitdiff
path: root/Semestr 4/aisd/pracownia2
diff options
context:
space:
mode:
authorFranciszek Malinka <franciszek.malinka@gmail.com>2021-04-08 15:00:33 +0200
committerFranciszek Malinka <franciszek.malinka@gmail.com>2021-04-08 15:00:33 +0200
commit2f83962f1799e94c8108c575d1c0d35868b06c4e (patch)
tree9ef3e16d3e80c8e44e93694e262199d8d5e6e7dc /Semestr 4/aisd/pracownia2
parentf64f7de412dd06affb0670831bdd117bde33a192 (diff)
Pracownia 4 aisd
Diffstat (limited to 'Semestr 4/aisd/pracownia2')
-rw-r--r--Semestr 4/aisd/pracownia2/gen.py24
-rwxr-xr-xSemestr 4/aisd/pracownia2/gen_test.sh24
2 files changed, 48 insertions, 0 deletions
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