Five weekends: Difference between revisions

Added Dart example
(→‎{{header|Racket}}: "months", not "weeks")
(Added Dart example)
Line 1,850:
 
Total number of years with no 5-weekend months: 29</pre>
 
 
=={{header|Dart}}==
<lang Dart>
main() {
var total = 0;
var empty = <int>[];
for (var year = 1900; year < 2101; year++) {
var months =
[1, 3, 5, 7, 8, 10, 12].where((m) => DateTime(year, m, 1).weekday == 5);
print('$year\t$months');
total += months.length;
if (months.isEmpty) empty.add(year);
}
print('Total: $total');
print('Year with none: $empty');
}
</lang>
{{out|Sample output}}
<pre style="height:30ex;overflow:scroll">
1900 ()
1901 (3)
1902 (8)
1903 (5)
1904 (1, 7)
...
2098 (8)
2099 (5)
2100 (1, 10)
Total: 201
Year with none: [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|Delphi}}==
Anonymous user