Five weekends: Difference between revisions

Added PicoLisp
(→‎{{header|J}}: longer but simpler to parse)
(Added PicoLisp)
Line 189:
Dreary years count: 29
</pre>
 
=={{header|PicoLisp}}==
<lang PicoLisp>(setq Lst
(make
(for Y (range 1900 2100)
(for M (range 1 12)
(and
(date Y M 31)
(= "Friday" (day (date Y M 1)))
(link (list (get *Mon M) Y)) ) ) ) ) )
 
(prinl "There are " (length Lst) " months with five weekends:")
(mapc println (head 5 Lst))
(prinl "...")
(mapc println (tail 5 Lst))
(prinl)
(setq Lst (diff (range 1900 2100) (uniq (mapcar cadr Lst))))
(prinl "There are " (length Lst) " years with no five-weekend months:")
(println Lst)</lang>
Output:
<pre>There are 201 months with five weekends:
(Mar 1901)
(Aug 1902)
(May 1903)
(Jan 1904)
(Jul 1904)
...
(Mar 2097)
(Aug 2098)
(May 2099)
(Jan 2100)
(Oct 2100)
 
There are 29 years with no five-weekend months:
(1900 1906 1917 1923 1928 1934 1945 1951 1956 1962 1973 1979 1984 1990 2001 2007
2012 2018 2029 2035 2040 2046 2057 2063 2068 2074 2085 2091 2096)</pre>
 
=={{header|Python}}==
Anonymous user