Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1,20 @@
$fiveWeekends = @()
$yearsWithout = @()
foreach ($y in 1900..2100) {
$hasFiveWeekendMonth = $FALSE
foreach ($m in @("01","03","05","07","08",10,12)) {
if ((Get-Date "$y-$m-1").DayOfWeek -eq "Friday") {
$fiveWeekends += "$y-$m"
$hasFiveWeekendMonth = $TRUE
}
}
if ($hasFiveWeekendMonth -eq $FALSE) {
$yearsWithout += $y
}
}
Write-Output "Between the years 1900 and 2100, inclusive, there are $($fiveWeekends.count) months with five full weekends:"
Write-Output "$($fiveWeekends[0..4] -join ","),...,$($fiveWeekends[-5..-1] -join ",")"
Write-Output ""
Write-Output "Extra Credit: these $($yearsWithout.count) years have no such month:"
Write-Output ($yearsWithout -join ",")