aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormjfernez <mjfernez@gmail.com>2020-03-06 18:55:37 -0500
committermjfernez <mjfernez@gmail.com>2020-03-06 18:55:37 -0500
commit009ce017d99a8deb2089438381c273e8f3ea3b67 (patch)
treea2f19d4d25c87efa503166ab83e82e5259534b3b
parent28d9d7226347e46527872d13671f316a1c943aed (diff)
downloadProject_Euler_Solutions-009ce017d99a8deb2089438381c273e8f3ea3b67.tar.gz
Added #19 Counting Sundays
-rw-r--r--[-rwxr-xr-x]01-Multiples-of-3-and-5/euler1bin8608 -> 8608 bytes
-rw-r--r--[-rwxr-xr-x]02-Even-Fibonacci-numbers/fibbin16776 -> 16776 bytes
-rw-r--r--[-rwxr-xr-x]03-Largest-Prime-Factor/largestprimebin16648 -> 16648 bytes
-rw-r--r--[-rwxr-xr-x]04-Largest-Palindrome-Product/palindromebin16824 -> 16824 bytes
-rw-r--r--[-rwxr-xr-x]05-Smallest-Multiple/smallmultbin16648 -> 16648 bytes
-rw-r--r--[-rwxr-xr-x]06-Sum-Square-Difference/sumsqbin16616 -> 16616 bytes
-rw-r--r--[-rwxr-xr-x]07-10001st-Prime/10001primebin16880 -> 16880 bytes
-rw-r--r--[-rwxr-xr-x]08-Largest-Product-In-a-Series/productofdigitsbin16680 -> 16680 bytes
-rw-r--r--[-rwxr-xr-x]09-Special-Pythagorean-Triplet/pythbin16704 -> 16704 bytes
-rw-r--r--[-rwxr-xr-x]10-Summation-of-Primes/sumofprimesbin16904 -> 16904 bytes
-rw-r--r--[-rwxr-xr-x]11-Largest-Product-In-Grid/prodgridbin10312 -> 10312 bytes
-rw-r--r--[-rwxr-xr-x]12-Highly-Divisible-Triangular-Number/bigfactors2bin16752 -> 16752 bytes
-rw-r--r--[-rwxr-xr-x]13-Large-Sum/largesumbin21744 -> 21744 bytes
-rw-r--r--[-rwxr-xr-x]14-Longest-Collatz-Sequence/collatzbin16696 -> 16696 bytes
-rw-r--r--[-rwxr-xr-x]15-Lattice-Paths/latticebin16760 -> 16760 bytes
-rw-r--r--[-rwxr-xr-x]16-Power-Digit-Sum/sumexpbin16800 -> 16800 bytes
-rw-r--r--[-rwxr-xr-x]17-Number-Letter-Counts/wordnumsbin17432 -> 17432 bytes
-rwxr-xr-x19-Counting-Sundays/countsundaysbin0 -> 16776 bytes
-rw-r--r--19-Counting-Sundays/countsundays.c29
19 files changed, 29 insertions, 0 deletions
diff --git a/01-Multiples-of-3-and-5/euler1 b/01-Multiples-of-3-and-5/euler1
index 585d380..585d380 100755..100644
--- a/01-Multiples-of-3-and-5/euler1
+++ b/01-Multiples-of-3-and-5/euler1
Binary files differ
diff --git a/02-Even-Fibonacci-numbers/fib b/02-Even-Fibonacci-numbers/fib
index e9b1b3b..e9b1b3b 100755..100644
--- a/02-Even-Fibonacci-numbers/fib
+++ b/02-Even-Fibonacci-numbers/fib
Binary files differ
diff --git a/03-Largest-Prime-Factor/largestprime b/03-Largest-Prime-Factor/largestprime
index c2afe6f..c2afe6f 100755..100644
--- a/03-Largest-Prime-Factor/largestprime
+++ b/03-Largest-Prime-Factor/largestprime
Binary files differ
diff --git a/04-Largest-Palindrome-Product/palindrome b/04-Largest-Palindrome-Product/palindrome
index f4d607f..f4d607f 100755..100644
--- a/04-Largest-Palindrome-Product/palindrome
+++ b/04-Largest-Palindrome-Product/palindrome
Binary files differ
diff --git a/05-Smallest-Multiple/smallmult b/05-Smallest-Multiple/smallmult
index 5f4e692..5f4e692 100755..100644
--- a/05-Smallest-Multiple/smallmult
+++ b/05-Smallest-Multiple/smallmult
Binary files differ
diff --git a/06-Sum-Square-Difference/sumsq b/06-Sum-Square-Difference/sumsq
index 8f8aa03..8f8aa03 100755..100644
--- a/06-Sum-Square-Difference/sumsq
+++ b/06-Sum-Square-Difference/sumsq
Binary files differ
diff --git a/07-10001st-Prime/10001prime b/07-10001st-Prime/10001prime
index a9cc351..a9cc351 100755..100644
--- a/07-10001st-Prime/10001prime
+++ b/07-10001st-Prime/10001prime
Binary files differ
diff --git a/08-Largest-Product-In-a-Series/productofdigits b/08-Largest-Product-In-a-Series/productofdigits
index 9d3f349..9d3f349 100755..100644
--- a/08-Largest-Product-In-a-Series/productofdigits
+++ b/08-Largest-Product-In-a-Series/productofdigits
Binary files differ
diff --git a/09-Special-Pythagorean-Triplet/pyth b/09-Special-Pythagorean-Triplet/pyth
index e778cfc..e778cfc 100755..100644
--- a/09-Special-Pythagorean-Triplet/pyth
+++ b/09-Special-Pythagorean-Triplet/pyth
Binary files differ
diff --git a/10-Summation-of-Primes/sumofprimes b/10-Summation-of-Primes/sumofprimes
index a175f6a..a175f6a 100755..100644
--- a/10-Summation-of-Primes/sumofprimes
+++ b/10-Summation-of-Primes/sumofprimes
Binary files differ
diff --git a/11-Largest-Product-In-Grid/prodgrid b/11-Largest-Product-In-Grid/prodgrid
index 5054666..5054666 100755..100644
--- a/11-Largest-Product-In-Grid/prodgrid
+++ b/11-Largest-Product-In-Grid/prodgrid
Binary files differ
diff --git a/12-Highly-Divisible-Triangular-Number/bigfactors2 b/12-Highly-Divisible-Triangular-Number/bigfactors2
index 3e409b1..3e409b1 100755..100644
--- a/12-Highly-Divisible-Triangular-Number/bigfactors2
+++ b/12-Highly-Divisible-Triangular-Number/bigfactors2
Binary files differ
diff --git a/13-Large-Sum/largesum b/13-Large-Sum/largesum
index 8c9de24..8c9de24 100755..100644
--- a/13-Large-Sum/largesum
+++ b/13-Large-Sum/largesum
Binary files differ
diff --git a/14-Longest-Collatz-Sequence/collatz b/14-Longest-Collatz-Sequence/collatz
index 37da709..37da709 100755..100644
--- a/14-Longest-Collatz-Sequence/collatz
+++ b/14-Longest-Collatz-Sequence/collatz
Binary files differ
diff --git a/15-Lattice-Paths/lattice b/15-Lattice-Paths/lattice
index 1f7bba2..1f7bba2 100755..100644
--- a/15-Lattice-Paths/lattice
+++ b/15-Lattice-Paths/lattice
Binary files differ
diff --git a/16-Power-Digit-Sum/sumexp b/16-Power-Digit-Sum/sumexp
index 854ac69..854ac69 100755..100644
--- a/16-Power-Digit-Sum/sumexp
+++ b/16-Power-Digit-Sum/sumexp
Binary files differ
diff --git a/17-Number-Letter-Counts/wordnums b/17-Number-Letter-Counts/wordnums
index dc75675..dc75675 100755..100644
--- a/17-Number-Letter-Counts/wordnums
+++ b/17-Number-Letter-Counts/wordnums
Binary files differ
diff --git a/19-Counting-Sundays/countsundays b/19-Counting-Sundays/countsundays
new file mode 100755
index 0000000..f5f9aa9
--- /dev/null
+++ b/19-Counting-Sundays/countsundays
Binary files differ
diff --git a/19-Counting-Sundays/countsundays.c b/19-Counting-Sundays/countsundays.c
new file mode 100644
index 0000000..e3f4d5a
--- /dev/null
+++ b/19-Counting-Sundays/countsundays.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <time.h>
+
+// Implemented a timing routine for fun :)
+
+int main(){
+ clock_t now, then;
+ int c = 0;
+ struct tm time = {0};
+
+ then = clock();
+ time.tm_mday = 1;
+
+ // Starting from 1-1-1901
+ for(int y = 1; y <= 100; y++){
+ for(int m = 0; m < 12; m++){ // Apparently January is the 0th month,
+ time.tm_mon = m; // even though there's no 0th day.... wtf K&R??
+ time.tm_year = y;
+ time_t inttime = mktime(&time);
+ struct tm *t = localtime(&inttime);
+ if(t->tm_wday == 0)
+ c++;
+ }
+ }
+ printf("%d\n", c);
+ now = clock();
+ printf("Only took %f ms\n", (double)(now - then) / (CLOCKS_PER_SEC / 1000));
+ return 0;
+}