diff options
author | mjfernez <mjfernez@gmail.com> | 2020-03-06 18:55:37 -0500 |
---|---|---|
committer | mjfernez <mjfernez@gmail.com> | 2020-03-06 18:55:37 -0500 |
commit | 009ce017d99a8deb2089438381c273e8f3ea3b67 (patch) | |
tree | a2f19d4d25c87efa503166ab83e82e5259534b3b | |
parent | 28d9d7226347e46527872d13671f316a1c943aed (diff) | |
download | Project_Euler_Solutions-009ce017d99a8deb2089438381c273e8f3ea3b67.tar.gz |
Added #19 Counting Sundays
-rw-r--r--[-rwxr-xr-x] | 01-Multiples-of-3-and-5/euler1 | bin | 8608 -> 8608 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 02-Even-Fibonacci-numbers/fib | bin | 16776 -> 16776 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 03-Largest-Prime-Factor/largestprime | bin | 16648 -> 16648 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 04-Largest-Palindrome-Product/palindrome | bin | 16824 -> 16824 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 05-Smallest-Multiple/smallmult | bin | 16648 -> 16648 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 06-Sum-Square-Difference/sumsq | bin | 16616 -> 16616 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 07-10001st-Prime/10001prime | bin | 16880 -> 16880 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 08-Largest-Product-In-a-Series/productofdigits | bin | 16680 -> 16680 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 09-Special-Pythagorean-Triplet/pyth | bin | 16704 -> 16704 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 10-Summation-of-Primes/sumofprimes | bin | 16904 -> 16904 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 11-Largest-Product-In-Grid/prodgrid | bin | 10312 -> 10312 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 12-Highly-Divisible-Triangular-Number/bigfactors2 | bin | 16752 -> 16752 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 13-Large-Sum/largesum | bin | 21744 -> 21744 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 14-Longest-Collatz-Sequence/collatz | bin | 16696 -> 16696 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 15-Lattice-Paths/lattice | bin | 16760 -> 16760 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 16-Power-Digit-Sum/sumexp | bin | 16800 -> 16800 bytes | |||
-rw-r--r--[-rwxr-xr-x] | 17-Number-Letter-Counts/wordnums | bin | 17432 -> 17432 bytes | |||
-rwxr-xr-x | 19-Counting-Sundays/countsundays | bin | 0 -> 16776 bytes | |||
-rw-r--r-- | 19-Counting-Sundays/countsundays.c | 29 |
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 Binary files differindex 585d380..585d380 100755..100644 --- a/01-Multiples-of-3-and-5/euler1 +++ b/01-Multiples-of-3-and-5/euler1 diff --git a/02-Even-Fibonacci-numbers/fib b/02-Even-Fibonacci-numbers/fib Binary files differindex e9b1b3b..e9b1b3b 100755..100644 --- a/02-Even-Fibonacci-numbers/fib +++ b/02-Even-Fibonacci-numbers/fib diff --git a/03-Largest-Prime-Factor/largestprime b/03-Largest-Prime-Factor/largestprime Binary files differindex c2afe6f..c2afe6f 100755..100644 --- a/03-Largest-Prime-Factor/largestprime +++ b/03-Largest-Prime-Factor/largestprime diff --git a/04-Largest-Palindrome-Product/palindrome b/04-Largest-Palindrome-Product/palindrome Binary files differindex f4d607f..f4d607f 100755..100644 --- a/04-Largest-Palindrome-Product/palindrome +++ b/04-Largest-Palindrome-Product/palindrome diff --git a/05-Smallest-Multiple/smallmult b/05-Smallest-Multiple/smallmult Binary files differindex 5f4e692..5f4e692 100755..100644 --- a/05-Smallest-Multiple/smallmult +++ b/05-Smallest-Multiple/smallmult diff --git a/06-Sum-Square-Difference/sumsq b/06-Sum-Square-Difference/sumsq Binary files differindex 8f8aa03..8f8aa03 100755..100644 --- a/06-Sum-Square-Difference/sumsq +++ b/06-Sum-Square-Difference/sumsq diff --git a/07-10001st-Prime/10001prime b/07-10001st-Prime/10001prime Binary files differindex a9cc351..a9cc351 100755..100644 --- a/07-10001st-Prime/10001prime +++ b/07-10001st-Prime/10001prime diff --git a/08-Largest-Product-In-a-Series/productofdigits b/08-Largest-Product-In-a-Series/productofdigits Binary files differindex 9d3f349..9d3f349 100755..100644 --- a/08-Largest-Product-In-a-Series/productofdigits +++ b/08-Largest-Product-In-a-Series/productofdigits diff --git a/09-Special-Pythagorean-Triplet/pyth b/09-Special-Pythagorean-Triplet/pyth Binary files differindex e778cfc..e778cfc 100755..100644 --- a/09-Special-Pythagorean-Triplet/pyth +++ b/09-Special-Pythagorean-Triplet/pyth diff --git a/10-Summation-of-Primes/sumofprimes b/10-Summation-of-Primes/sumofprimes Binary files differindex a175f6a..a175f6a 100755..100644 --- a/10-Summation-of-Primes/sumofprimes +++ b/10-Summation-of-Primes/sumofprimes diff --git a/11-Largest-Product-In-Grid/prodgrid b/11-Largest-Product-In-Grid/prodgrid Binary files differindex 5054666..5054666 100755..100644 --- a/11-Largest-Product-In-Grid/prodgrid +++ b/11-Largest-Product-In-Grid/prodgrid diff --git a/12-Highly-Divisible-Triangular-Number/bigfactors2 b/12-Highly-Divisible-Triangular-Number/bigfactors2 Binary files differindex 3e409b1..3e409b1 100755..100644 --- a/12-Highly-Divisible-Triangular-Number/bigfactors2 +++ b/12-Highly-Divisible-Triangular-Number/bigfactors2 diff --git a/13-Large-Sum/largesum b/13-Large-Sum/largesum Binary files differindex 8c9de24..8c9de24 100755..100644 --- a/13-Large-Sum/largesum +++ b/13-Large-Sum/largesum diff --git a/14-Longest-Collatz-Sequence/collatz b/14-Longest-Collatz-Sequence/collatz Binary files differindex 37da709..37da709 100755..100644 --- a/14-Longest-Collatz-Sequence/collatz +++ b/14-Longest-Collatz-Sequence/collatz diff --git a/15-Lattice-Paths/lattice b/15-Lattice-Paths/lattice Binary files differindex 1f7bba2..1f7bba2 100755..100644 --- a/15-Lattice-Paths/lattice +++ b/15-Lattice-Paths/lattice diff --git a/16-Power-Digit-Sum/sumexp b/16-Power-Digit-Sum/sumexp Binary files differindex 854ac69..854ac69 100755..100644 --- a/16-Power-Digit-Sum/sumexp +++ b/16-Power-Digit-Sum/sumexp diff --git a/17-Number-Letter-Counts/wordnums b/17-Number-Letter-Counts/wordnums Binary files differindex dc75675..dc75675 100755..100644 --- a/17-Number-Letter-Counts/wordnums +++ b/17-Number-Letter-Counts/wordnums diff --git a/19-Counting-Sundays/countsundays b/19-Counting-Sundays/countsundays Binary files differnew file mode 100755 index 0000000..f5f9aa9 --- /dev/null +++ b/19-Counting-Sundays/countsundays 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; +} |