How to resolve the algorithm Five weekends step by step in the AutoHotkey programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Five weekends step by step in the AutoHotkey programming language
Table of Contents
Problem Statement
The month of October in 2010 has five Fridays, five Saturdays, and five Sundays.
Algorithm suggestions
Extra credit Count and/or show all of the years which do not have at least one five-weekend month (there should be 29).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Five weekends step by step in the AutoHotkey programming language
Source code in the autohotkey programming language
Year := 1900
End_Year := 2100
31_Day_Months = 01,03,05,07,08,10,12
While Year <= End_Year
{
Loop, Parse, 31_Day_Months, CSV
{
FormatTime, Day, %Year%%A_LoopField%01, dddd
IfEqual, Day, Friday
{
All_Months_With_5_Weekends .= A_LoopField . "/" . Year ", "
5_Weekend_Count++
Year_Has_5_Weekend_Month := 1
}
}
IfEqual, Year_Has_5_Weekend_Month, 0
{
All_Years_Without_5_Weekend .= Year ", "
No_5_Weekend_Count ++
}
Year ++
Year_Has_5_Weekend_Month := 0
}
; Trim the spaces and comma off the last item.
StringTrimRight, All_Months_With_5_Weekends, All_Months_With_5_Weekends, 5
StringTrimRight, All_Years_Without_5_Weekend, All_Years_Without_5_Weekend, 4
MsgBox,
(
Months with 5 day weekends between 1900 and 2100 : %5_Weekend_Count%
%All_Months_With_5_Weekends%
)
MsgBox,
(
Years with no 5 day weekends between 1900 and 2100 : %No_5_Weekend_Count%
%All_Years_Without_5_Weekend%
)
You may also check:How to resolve the algorithm Monads/Writer monad step by step in the Wren programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Scala programming language
You may also check:How to resolve the algorithm Percolation/Mean cluster density step by step in the C programming language
You may also check:How to resolve the algorithm Spiral matrix step by step in the J programming language
You may also check:How to resolve the algorithm File input/output step by step in the ACL2 programming language