Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/Five-weekends/PowerShell/five-weekends.psh
Normal file
20
Task/Five-weekends/PowerShell/five-weekends.psh
Normal 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 ",")
|
||||
Loading…
Add table
Add a link
Reference in a new issue