-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem19.cmd
More file actions
36 lines (33 loc) · 866 Bytes
/
Problem19.cmd
File metadata and controls
36 lines (33 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@ECHO OFF
SETLOCAL EnableDelayedExpansion
:: Problem 19
:: How many Sundays fell on the first of the month during the 20th century?
:: (1-Jan-1901 to 31-Dec-2000)
SET SunCount=0
SET Days=1
FOR /L %%Y IN (0,1,100) DO (
FOR /L %%M IN (1,1,12) DO (
SET /A SunCheck = Days %% 7
IF !SunCheck! EQU 0 (
IF %%Y GEQ 1 SET /A SunCount+=1
)
IF %%M EQU 1 SET /A Days+=31
IF %%M EQU 2 (
SET /A LeapCheck = %%Y %% 4
IF !LeapCheck! EQU 0 (
SET /A Days+=29
) ELSE SET /A Days+=28
)
IF %%M EQU 3 SET /A Days+=31
IF %%M EQU 4 SET /A Days+=30
IF %%M EQU 5 SET /A Days+=31
IF %%M EQU 6 SET /A Days+=30
IF %%M EQU 7 SET /A Days+=31
IF %%M EQU 8 SET /A Days+=31
IF %%M EQU 9 SET /A Days+=30
IF %%M EQU 10 SET /A Days+=31
IF %%M EQU 11 SET /A Days+=30
IF %%M EQU 12 SET /A Days+=31
)
)
ECHO:%SunCount%