From f66d1963798b688b8bc551c05c5db1e53a828f50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?tom=C3=A1s=20zerolo?= Date: Sun, 20 Nov 2022 14:38:31 +0100 Subject: [PATCH] coinflip flips coins --- coinflip.py | 17 +++++++++++++++++ notes | 2 ++ 2 files changed, 19 insertions(+) create mode 100755 coinflip.py create mode 100644 notes diff --git a/coinflip.py b/coinflip.py new file mode 100755 index 0000000..7a5f62d --- /dev/null +++ b/coinflip.py @@ -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]} \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 index 0000000..ef9e7aa --- /dev/null +++ b/notes @@ -0,0 +1,2 @@ +# -*- mode: org -*- +#+title: bernoulli stuff -- 2.30.2