Five weekends: Difference between revisions

Added Quackery.
(Updated to work with version 1.4 of Nim.)
(Added Quackery.)
Line 5,280:
 
There are 29 years in the range that do not have months with five weekends</pre>
 
=={{header|Quackery}}==
 
<lang Quackery> [ over 3 < if [ 1 - ]
dup 4 / over +
over 100 / -
swap 400 / +
swap 1 -
[ table
0 3 2 5 0 3
5 1 4 6 2 4 ]
+ + 7 mod ] is dayofweek ( day month year --> weekday )
 
[ 1 -
[ table
$ "January" $ "February"
$ "March" $ "April"
$ "May" $ "June"
$ "July" $ "August"
$ "September" $ "October"
$ "November" $ "December" ]
do ] is monthname ( monthnumber --> $ )
[] [] temp put
201 times
[ true temp put
i^ 1900 +
' [ 1 3 5 7 8 10 12 ]
witheach
[ 2dup swap
1 unrot dayofweek
5 = iff
[ false temp replace
over join nested
swap dip join ]
else drop ]
temp take iff
[ temp take
swap join
temp put ]
else drop ]
temp take swap
5 split swap
say "Five weekends: "
witheach
[ do swap
monthname echo$
sp echo
i if say ", " ]
cr say " ..."
cr space 15 of echo$
-5 split nip
witheach
[ do swap
monthname echo$
sp echo
i if say ", " ]
cr cr
say "Years without five weekends: "
witheach
[ echo
i if say ", "
i^ 8 mod 7 = if
[ cr space 29 of echo$ ] ]</lang>
 
{{out}}
 
<pre>Five weekends: March 1901, August 1902, May 1903, January 1904, July 1904
...
March 2097, August 2098, May 2099, January 2100, October 2100
 
Years without five weekends: 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|R}}==
1,462

edits