diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2021-08-08 18:22:21 +0200 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2021-08-08 18:22:21 +0200 |
commit | 3e73c192104ce843e351c986a65618fb4fae70e8 (patch) | |
tree | 72c08db3c439bec8e97f01f373a9d449c202597d | |
parent | 6c11d8fe0a92fcbcc704f0c0483abb40b4eedd54 (diff) |
problem 19
-rw-r--r-- | problem19.ijs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/problem19.ijs b/problem19.ijs new file mode 100644 index 0000000..6b92cdf --- /dev/null +++ b/problem19.ijs @@ -0,0 +1,32 @@ +isleap =: monad define + divBy4 =. 0=4|y + divBy100 =. 0=100|y + divBy400 =. 0=400|y + divBy4*.divBy400+.-.divBy100 +) + +daysInMonth =: dyad define + feb =. (isleap x){28 29 + y{31,feb, 31 30 31 30 31 31 30 31 30 31 +) + +nextMonthStart =: monad define + ('year';'month';'day') =. y + days =. year daysInMonth month + day =. 7 | days + day + if. month = 11 do. + (year+1);0;day + else. + year;(month+1);day + end. +) + +start =: nextMonthStart^:12 (1900;0;0) + +generateMonths =: 13 : '(nextMonthStart^:y) start' + +months =: generateMonths i. 1199 + +startedOnSunday =: 6 = [: > 2 { ] + +result =: +/startedOnSunday"1 months
\ No newline at end of file |