From 8564d3de284df4f591e2be1113619e3501c97fb6 Mon Sep 17 00:00:00 2001 From: Lowl3v3l Date: Tue, 11 Jul 2017 16:56:15 +0200 Subject: [PATCH 1/4] solved 47 in racket, ugly code --- 47/euler47.rkt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 47/euler47.rkt diff --git a/47/euler47.rkt b/47/euler47.rkt new file mode 100644 index 0000000..0c27b85 --- /dev/null +++ b/47/euler47.rkt @@ -0,0 +1,22 @@ +#lang racket + +(require math/number-theory) + +(define (primefactors x) + (if (prime? x) + (list x) + (for/or ((i (cons 2 (range 3 (+ 1 (ceiling (sqrt x))) 2))) + #:when (prime? i) + #:when (zero? (remainder x i))) + (cons i (primefactors (quotient x i)))))) + +(define (recur x) + (if (and + (equal? (length (remove-duplicates (primefactors x))) 4) + (equal? (length (remove-duplicates (primefactors (+ x 1)))) 4) + (equal? (length (remove-duplicates (primefactors (+ x 2)))) 4) + (equal? (length (remove-duplicates (primefactors (+ x 3)))) 4)) + x + (recur (+ x 1)))) + +(recur 2) \ No newline at end of file From 13036fb7f629637ba01f7a8b3e12c35291244fd4 Mon Sep 17 00:00:00 2001 From: pikatech Date: Tue, 11 Jul 2017 20:18:46 +0200 Subject: [PATCH 2/4] Python one-liner --- 16/euler16.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 16/euler16.py diff --git a/16/euler16.py b/16/euler16.py new file mode 100644 index 0000000..5ffb667 --- /dev/null +++ b/16/euler16.py @@ -0,0 +1 @@ +sum([int(x) for x in list(str(2**1000))]) From b08bd9a3a7632f209938c2871c7453f57deffd6a Mon Sep 17 00:00:00 2001 From: pikatech Date: Tue, 11 Jul 2017 20:23:22 +0200 Subject: [PATCH 3/4] Essentially euler 16 plus an import. --- 20/euler20.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 20/euler20.py diff --git a/20/euler20.py b/20/euler20.py new file mode 100644 index 0000000..1392e9d --- /dev/null +++ b/20/euler20.py @@ -0,0 +1,2 @@ +import math +sum([int(x) for x in list(str(math.factorial(100)))]) From c280f28d0ae6dbdcc5c96b3b3c6abf979f582e66 Mon Sep 17 00:00:00 2001 From: pikatech Date: Tue, 11 Jul 2017 20:31:39 +0200 Subject: [PATCH 4/4] Another python one-liner. --- 48/euler48.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 48/euler48.py diff --git a/48/euler48.py b/48/euler48.py new file mode 100644 index 0000000..58ce145 --- /dev/null +++ b/48/euler48.py @@ -0,0 +1 @@ +str(sum([x**x for x in range(1,1001)]))[-10:]