From 3e73c192104ce843e351c986a65618fb4fae70e8 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Sun, 8 Aug 2021 18:22:21 +0200 Subject: problem 19 --- problem19.ijs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 problem19.ijs 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 -- cgit v1.2.3