From c712043c4cfe774c4db08b8a33c4478d209d79b6 Mon Sep 17 00:00:00 2001 From: Philippe Zwietering Date: Tue, 6 Apr 2021 10:19:08 +0200 Subject: [PATCH] Gotta love these easy ones --- 53/main.py | 40 ++++++++++++++++++++++++++++++++++++++++ base.py | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 53/main.py diff --git a/53/main.py b/53/main.py new file mode 100644 index 0000000..d149d33 --- /dev/null +++ b/53/main.py @@ -0,0 +1,40 @@ +''' +There are exactly ten ways of selecting three from five, 12345: + +123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 + +In combinatorics, we use the notation, +. + +In general, + +, where , , and . + +It is not until , that a value exceeds one-million: +. + +How many, not necessarily distinct, values of + for , are greater than one-million? + ''' +# Okay I have to admit that it looks really bad without the math equations + +import time +import math + + +def main(): + print("Hello, this is Patrick") + t0 = time.time() + + tooBig = 1000000 + counter = 0 + + for n in range(1, 101): + for r in range(1, n+1): + if math.comb(n, r) > tooBig: + counter += 1 + + print(counter, time.time() - t0) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/base.py b/base.py index f4c0059..f50355c 100644 --- a/base.py +++ b/base.py @@ -4,7 +4,7 @@ import math def main(): print("Hello, this is Patrick") - + t0 = time.time() if __name__ == "__main__": main() \ No newline at end of file