Five weekends: Difference between revisions
Content added Content deleted
No edit summary |
(added Factor) |
||
Line 2,223: | Line 2,223: | ||
29 years in the range of years from 1900 to 2100 have no month with 5 weekends. |
29 years in the range of years from 1900 to 2100 have no month with 5 weekends. |
||
Months with 5 weekends: [(1901, [3]); (1902, [8]); (1903, [5]); (1904, [1; 7]); (1905, [12])] ... [(2095, [7]); (2097, [3]); (2098, [8]); (2099, [5]); (2100, [1; 10])]</pre> |
Months with 5 weekends: [(1901, [3]); (1902, [8]); (1903, [5]); (1904, [1; 7]); (1905, [12])] ... [(2095, [7]); (2097, [3]); (2098, [8]); (2099, [5]); (2100, [1; 10])]</pre> |
||
=={{header|Factor}}== |
|||
<lang factor>USING: calendar calendar.format formatting fry io kernel math |
|||
sequences ; |
|||
IN: rosetta-code.five-weekends |
|||
: timestamps>my ( months -- ) |
|||
[ { MONTH bl YYYY nl } formatted 2drop ] each ; |
|||
: month-range ( start-year #months -- seq ) |
|||
'[ _ <year> _ <iota> ] call [ months time+ ] with map ; |
|||
: find-five-weekend-months ( months -- months' ) |
|||
[ [ friday? ] [ days-in-month ] bi 31 = and ] filter ; |
|||
1900 12 201 * month-range find-five-weekend-months |
|||
[ length "%d five-weekend months found.\n" printf ] |
|||
[ 5 head timestamps>my "..." print ] |
|||
[ 5 tail* timestamps>my ] tri</lang> |
|||
{{out}} |
|||
<pre> |
|||
201 five-weekend months found. |
|||
Mar 1901 |
|||
Aug 1902 |
|||
May 1903 |
|||
Jan 1904 |
|||
Jul 1904 |
|||
... |
|||
Mar 2097 |
|||
Aug 2098 |
|||
May 2099 |
|||
Jan 2100 |
|||
Oct 2100 |
|||
</pre> |
|||
=={{header|Fortran}}== |
=={{header|Fortran}}== |