coinflip flips coins
authortomás zerolo <tomas@tuxteam.de>
Sun, 20 Nov 2022 13:38:31 +0000 (14:38 +0100)
committertomás zerolo <tomas@tuxteam.de>
Sun, 20 Nov 2022 13:38:31 +0000 (14:38 +0100)
coinflip.py [new file with mode: 0755]
notes [new file with mode: 0644]

diff --git a/coinflip.py b/coinflip.py
new file mode 100755 (executable)
index 0000000..7a5f62d
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/python3
+
+import sys
+from random import random
+
+def flipcoins (n):
+  return [int(2*random()) for i in range(n-1)]
+
+if len(sys.argv) != 3:
+  print(f"Usage: {sys.argv[0]} <flips> <repeats>\n")
+  exit(1)
+
+flips = int(sys.argv[1])
+repeats = int(sys.argv[2])
+
+for i in range(repeats - 1):
+  print(flipcoins(flips))
diff --git a/notes b/notes
new file mode 100644 (file)
index 0000000..ef9e7aa
--- /dev/null
+++ b/notes
@@ -0,0 +1,2 @@
+# -*- mode: org -*-
+#+title: bernoulli stuff