05AB1E , (削除) 130 (削除ここまで)(削除) 128 (削除ここまで)(削除) 133 (削除ここまで)(削除) 131 (削除ここまで)(削除) 124 (削除ここまで)(削除) 123 (削除ここまで)(削除) 122 (削除ここまで) 121 bytes
05AB1E , (削除) 130 (削除ここまで)(削除) 128 (削除ここまで)(削除) 133 (削除ここまで)(削除) 131 (削除ここまで)(削除) 124 (削除ここまで)(削除) 123 (削除ここまで)(削除) 122 (削除ここまで)(削除) 121 (削除ここまで) 120 bytes
žežfžg)V0[Y`UD3‹©12*+>2*T÷®Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi28円X+ë<7%É31αćsO7%2@+Y`т‰0Kθ4ÖUD<i28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
Try it online Try it online or Try it online with an emulated self-specified date of 'today' Try it online with an emulated self-specified date of 'today'.
D # Duplicate the month that is now the top of the stack
2Q< # Check if# it'sDecrease equalit toby 21
i # And if itthis is now 1 (thus February):
\ # Remove the duplicated month from the top of the stack
28X+ # Add 28 and variable `X` (the isLeapYear) together
05AB1E , (削除) 130 (削除ここまで)(削除) 128 (削除ここまで)(削除) 133 (削除ここまで)(削除) 131 (削除ここまで)(削除) 124 (削除ここまで)(削除) 123 (削除ここまで)(削除) 122 (削除ここまで) 121 bytes
žežfžg)V0[Y`UD3‹©12*+>2*T÷®Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
Try it online or Try it online with an emulated self-specified date of 'today'.
D # Duplicate the month that is now the top of the stack
2Q # Check if it's equal to 2
i # And if it is:
\ # Remove the duplicated month from the top of the stack
28X+ # Add 28 and variable `X` (the isLeapYear) together
05AB1E , (削除) 130 (削除ここまで)(削除) 128 (削除ここまで)(削除) 133 (削除ここまで)(削除) 131 (削除ここまで)(削除) 124 (削除ここまで)(削除) 123 (削除ここまで)(削除) 122 (削除ここまで)(削除) 121 (削除ここまで) 120 bytes
žežfžg)V0[Y`UD3‹©12*+>2*T÷®Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD<i28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
Try it online or Try it online with an emulated self-specified date of 'today'.
D # Duplicate the month that is now the top of the stack
< # Decrease it by 1
i # And if this is now 1 (thus February):
\ # Remove the duplicated month from the top of the stack
28X+ # Add 28 and variable `X` (the isLeapYear) together
#05AB1E , (削除) 130 (削除ここまで)(削除) 128 (削除ここまで)(削除) 133 (削除ここまで)(削除) 131 (削除ここまで)(削除) 124 (削除ここまで)(削除) 123 (削除ここまで) 122 bytes
05AB1E , (削除) 130 (削除ここまで)(削除) 128 (削除ここまで)(削除) 133 (削除ここまで)(削除) 131 (削除ここまで)(削除) 124 (削除ここまで)(削除) 123 (削除ここまで)(削除) 122 (削除ここまで) 121 bytes
žežfžg)V0[Y`UÐ3‹12*+>2*T÷s3‹Xα©т%D4÷®т÷©4÷®·V0[Y`UD3‹©12*+>2*T÷®Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
Try it online Try it online or Try it online with an emulated self-specified date of 'today' Try it online with an emulated self-specified date of 'today'.
###Explanation:
Explanation:
Date currentDate = today;is this part of the 05AB1E program:
1) Date currentDate = today; is this part of the 05AB1E program:
Integer counter = 0;and 3)Start an infinite loop:are straight-forward in the 05AB1E program:
2) Integer counter = 0; and 3) Start an infinite loop: are straight-forward in the 05AB1E program:
If(currentDate is NOT a Saturday and currentDate is NOT a Sunday):is the first hard part with manual calculations. Since 05AB1E has no Date builtins, we'll have to calculate the Day of the Week manually.
4) If(currentDate is NOT a Saturday and currentDate is NOT a Sunday): is the first hard part with manual calculations. Since 05AB1E has no Date builtins, we'll have to calculate the Day of the Week manually.
Y # Push variable `Y`
` # Push the day, month, and year to the stack
U # Pop and save the year in variable `X`
ÐD # TriplicateDuplicate the month
3‹ # Check if the month is below 3 (Jan. / Feb.),
# resulting in 1 or 0 for truthy/falsey respectively
12*© # MultiplyStore this in variable `®` (without popping)
12* # Multiply it by 12 (either 0 or 12)
+ + # And add it to the month
# This first part was to make Jan. / Feb. 13 and 14
> # Month + 1
2* # Multiplied by 26
T÷ # Integer-divided by 10
s3‹® # Check if# thePush monthmonth<3 isfrom belowvariable 3`®` again (resulting in 1 / 0)
Xα Xα # Take the absolute difference with the year
© © # Store this potentially modified year inas thenew register
`®` (without popping)
т% # mYear modulo-100
D4÷ # mYear modulo-100, integer-divided by 4
®т÷©4÷ # mYear integer-divided by 100, and then integer-divided by 4
®·( # mYear integer-divided by 100, doubled, and then made negative
) # Wrap the entire stack into a list
ć # Extract the head (the counter variable that was also on the stack)
s # Swap so the calculated values above are as list at the top
O # Take the sum of this entire list
7% # And then take modulo-7 to complete the formula,
# resulting in 0 for Saturday, 1 for Sunday, and [2, 6] for [Monday, Friday]
2@ # Check if the day is greater than or equal to 2 (so a working day)
Counter += 1;is straight-forward again:
5) Counter += 1; is straight-forward again:
currentDate += 1; // Set currentDate to the next day in lineis again more complex, because we have to do it manually. So this will be expanded to the following pseudo-code:a Integer isLeapYear = ...; b Integer daysInCurrentMonth = currentDate.month == 2 ? c 28 + isLeapYear d : e 31 - (currentDate.month - 1) % 7 % 2; f If(currentDate.day < daysInCurrentMonth): g nextDate.day += 1; h Else: i nextDate.day = 1; j If(currentDate.month < 12): k nextDate.month += 1; l Else: m nextDate.month = 1; n nextDate.year += 1;
6) currentDate += 1; // Set currentDate to the next day in line is again more complex, because we have to do it manually. So this will be expanded to the following pseudo-code:
a Integer isLeapYear = ...;
b Integer daysInCurrentMonth = currentDate.month == 2 ?
c 28 + isLeapYear
d :
e 31 - (currentDate.month - 1) % 7 % 2;
f If(currentDate.day < daysInCurrentMonth):
g nextDate.day += 1;
h Else:
i nextDate.day = 1;
j If(currentDate.month < 12):
k nextDate.month += 1;
l Else:
m nextDate.month = 1;
n nextDate.year += 1;
And finally at 87) If(currentDate == parsed input-string): and 98) Stop the infinite loop, and output the counter:
#05AB1E , (削除) 130 (削除ここまで)(削除) 128 (削除ここまで)(削除) 133 (削除ここまで)(削除) 131 (削除ここまで)(削除) 124 (削除ここまで)(削除) 123 (削除ここまで) 122 bytes
žežfžg)V0[Y`UÐ3‹12*+>2*T÷s3‹Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
Try it online or Try it online with an emulated self-specified date of 'today'.
###Explanation:
Date currentDate = today;is this part of the 05AB1E program:
Integer counter = 0;and 3)Start an infinite loop:are straight-forward in the 05AB1E program:
If(currentDate is NOT a Saturday and currentDate is NOT a Sunday):is the first hard part with manual calculations. Since 05AB1E has no Date builtins, we'll have to calculate the Day of the Week manually.
Y # Push variable `Y`
` # Push the day, month, and year to the stack
U # Pop and save the year in variable `X`
Ð # Triplicate the month
3‹ # Check if the month is below 3 (Jan. / Feb.),
# resulting in 1 or 0 for truthy/falsey respectively
12* # Multiply this by 12 (either 0 or 12)
+ # And add it to the month
# This first part was to make Jan. / Feb. 13 and 14
> # Month + 1
2* # Multiplied by 26
T÷ # Integer-divided by 10
s3‹ # Check if the month is below 3 again (resulting in 1 / 0)
Xα # Take the absolute difference with the year
© # Store this potentially modified year in the register
т% # mYear modulo-100
D4÷ # mYear modulo-100, integer-divided by 4
®т÷©4÷ # mYear integer-divided by 100, and then integer-divided by 4
®·( # mYear integer-divided by 100, doubled, and then made negative
) # Wrap the entire stack into a list
ć # Extract the head (the counter variable that was also on the stack)
s # Swap so the calculated values above are as list at the top
O # Take the sum of this entire list
7% # And then take modulo-7 to complete the formula,
# resulting in 0 for Saturday, 1 for Sunday, and [2, 6] for [Monday, Friday]
2@ # Check if the day is greater than or equal to 2 (so a working day)
Counter += 1;is straight-forward again:
currentDate += 1; // Set currentDate to the next day in lineis again more complex, because we have to do it manually. So this will be expanded to the following pseudo-code:a Integer isLeapYear = ...; b Integer daysInCurrentMonth = currentDate.month == 2 ? c 28 + isLeapYear d : e 31 - (currentDate.month - 1) % 7 % 2; f If(currentDate.day < daysInCurrentMonth): g nextDate.day += 1; h Else: i nextDate.day = 1; j If(currentDate.month < 12): k nextDate.month += 1; l Else: m nextDate.month = 1; n nextDate.year += 1;
And finally at 8) If(currentDate == parsed input-string): and 9) Stop the infinite loop, and output the counter:
05AB1E , (削除) 130 (削除ここまで)(削除) 128 (削除ここまで)(削除) 133 (削除ここまで)(削除) 131 (削除ここまで)(削除) 124 (削除ここまで)(削除) 123 (削除ここまで)(削除) 122 (削除ここまで) 121 bytes
žežfžg)V0[Y`UD3‹©12*+>2*T÷®Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
Try it online or Try it online with an emulated self-specified date of 'today'.
Explanation:
1) Date currentDate = today; is this part of the 05AB1E program:
2) Integer counter = 0; and 3) Start an infinite loop: are straight-forward in the 05AB1E program:
4) If(currentDate is NOT a Saturday and currentDate is NOT a Sunday): is the first hard part with manual calculations. Since 05AB1E has no Date builtins, we'll have to calculate the Day of the Week manually.
Y # Push variable `Y`
` # Push the day, month, and year to the stack
U # Pop and save the year in variable `X`
D # Duplicate the month
3‹ # Check if the month is below 3 (Jan. / Feb.),
# resulting in 1 or 0 for truthy/falsey respectively
© # Store this in variable `®` (without popping)
12* # Multiply it by 12 (either 0 or 12)
+ # And add it to the month
# This first part was to make Jan. / Feb. 13 and 14
> # Month + 1
2* # Multiplied by 26
T÷ # Integer-divided by 10
® # Push month<3 from variable `®` again
Xα # Take the absolute difference with the year
© # Store this potentially modified year as new `®` (without popping)
т% # mYear modulo-100
D4÷ # mYear modulo-100, integer-divided by 4
®т÷©4÷ # mYear integer-divided by 100, and then integer-divided by 4
®·( # mYear integer-divided by 100, doubled, and then made negative
) # Wrap the entire stack into a list
ć # Extract the head (the counter variable that was also on the stack)
s # Swap so the calculated values above are as list at the top
O # Take the sum of this entire list
7% # And then take modulo-7 to complete the formula,
# resulting in 0 for Saturday, 1 for Sunday, and [2, 6] for [Monday, Friday]
2@ # Check if the day is greater than or equal to 2 (so a working day)
5) Counter += 1; is straight-forward again:
6) currentDate += 1; // Set currentDate to the next day in line is again more complex, because we have to do it manually. So this will be expanded to the following pseudo-code:
a Integer isLeapYear = ...;
b Integer daysInCurrentMonth = currentDate.month == 2 ?
c 28 + isLeapYear
d :
e 31 - (currentDate.month - 1) % 7 % 2;
f If(currentDate.day < daysInCurrentMonth):
g nextDate.day += 1;
h Else:
i nextDate.day = 1;
j If(currentDate.month < 12):
k nextDate.month += 1;
l Else:
m nextDate.month = 1;
n nextDate.year += 1;
And finally at 7) If(currentDate == parsed input-string): and 8) Stop the infinite loop, and output the counter:
#05AB1E, (削除) 130 (削除ここまで) (削除) 128 (削除ここまで) (削除) 133 (削除ここまで) (削除) 131 (削除ここまで) (削除) 124 (削除ここまで) 123(削除) 123 (削除ここまで) 122 bytes
žežfžg)V0[Y`UÐ3‹12*+>13*5÷s3‹Xα©т%D4÷®т÷©4÷®·V0[Y`UÐ3‹12*+>2*T÷s3‹Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
+5 bytes due to a part I forgot in Zeller's formula (year-1 for months January and February)..
-1 byte thanks to @Grimmy, by changing \$\left\lfloor{\frac{13(m+1)}{5}}\right\rfloor\$ to \$\left\lfloor{\frac{26(m+1)}{10}}\right\rfloor\$ in the code, since 05AB1E has single-byte builtins for both 26 and 10 (being 2 and T respectively), as opposed to the 3 bytes of 13 and 5.
Try it online Try it online or Try it online with an emulated self-specified date of 'today' Try it online with an emulated self-specified date of 'today'.
$${\displaystyle h=\left(q+\left\lfloor {\frac {13(m+1)}{5}}\right\rfloor +K+\left\lfloor {\frac {K}{4}}\right\rfloor +\left\lfloor {\frac {J}{4}}\right\rfloor -2J\right){\bmod {7}},}$$$${\displaystyle h=\left(q+\left\lfloor{\frac{13(m+1)}{5}}\right\rfloor+K+\left\lfloor{\frac{K}{4}}\right\rfloor+\left\lfloor{\frac{J}{4}}\right\rfloor-2J\right){\bmod{7}}}$$
Y # Push variable `Y`
` # Push the day, month, and year to the stack
U # Pop and save the year in variable `X`
Ð # Triplicate the month
3‹ # Check if the month is below 3 (Jan. / Feb.),
# resulting in 1 or 0 for truthy/falsey respectively
12* # Multiply this by 12 (either 0 or 12)
+ # And add it to the month
# This first part was to make Jan. / Feb. 13 and 14
> # Month + 1
13*2* # Multiplied by 1326
T÷ 5÷ # Integer-divided by 510
s3‹ # Check if the month is below 3 again (resulting in 1 / 0)
Xα # Take the absolute difference with the year
© # Store this potentially modified year in the register
т% # mYear modulo-100
D4÷ # mYear modulo-100, integer-divided by 4
®т÷©4÷ # mYear integer-divided by 100, and then integer-divided by 4
®·( # mYear integer-divided by 100, doubled, and then made negative
) # Wrap the entire stack into a list
ć # Extract the head (the counter variable that was also on the stack)
s # Swap so the calculated values above are as list at the top
O # Take the sum of this entire list
7% # And then take modulo-7 to complete the formula,
# resulting in 0 for Saturday, 1 for Sunday, and [2, 6] for [Monday, Friday]
2@ # Check if the day is greater than or equal to 2 (so a working day)
#05AB1E, (削除) 130 (削除ここまで) (削除) 128 (削除ここまで) (削除) 133 (削除ここまで) (削除) 131 (削除ここまで) (削除) 124 (削除ここまで) 123 bytes
žežfžg)V0[Y`UÐ3‹12*+>13*5÷s3‹Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
+5 bytes due to a part I forgot in Zeller's formula (year-1 for months January and February)..
Try it online or Try it online with an emulated self-specified date of 'today'.
$${\displaystyle h=\left(q+\left\lfloor {\frac {13(m+1)}{5}}\right\rfloor +K+\left\lfloor {\frac {K}{4}}\right\rfloor +\left\lfloor {\frac {J}{4}}\right\rfloor -2J\right){\bmod {7}},}$$
Y # Push variable `Y`
` # Push the day, month, and year to the stack
U # Pop and save the year in variable `X`
Ð # Triplicate the month
3‹ # Check if the month is below 3 (Jan. / Feb.),
# resulting in 1 or 0 for truthy/falsey respectively
12* # Multiply this by 12 (either 0 or 12)
+ # And add it to the month
# This first part was to make Jan. / Feb. 13 and 14
> # Month + 1
13* # Multiplied by 13
5÷ # Integer-divided by 5
s3‹ # Check if the month is below 3 again (resulting in 1 / 0)
Xα # Take the absolute difference with the year
© # Store this potentially modified year in the register
т% # mYear modulo-100
D4÷ # mYear modulo-100, integer-divided by 4
®т÷©4÷ # mYear integer-divided by 100, and then integer-divided by 4
®·( # mYear integer-divided by 100, doubled, and then made negative
) # Wrap the entire stack into a list
ć # Extract the head (the counter variable that was also on the stack)
s # Swap so the calculated values above are as list at the top
O # Take the sum of this entire list
7% # And then take modulo-7 to complete the formula,
# resulting in 0 for Saturday, 1 for Sunday, and [2, 6] for [Monday, Friday]
2@ # Check if the day is greater than or equal to 2 (so a working day)
#05AB1E, (削除) 130 (削除ここまで) (削除) 128 (削除ここまで) (削除) 133 (削除ここまで) (削除) 131 (削除ここまで) (削除) 124 (削除ここまで) (削除) 123 (削除ここまで) 122 bytes
žežfžg)V0[Y`UÐ3‹12*+>2*T÷s3‹Xα©т%D4÷®т÷©4÷®·()ćsO7%2@+Y`т‰0Kθ4ÖUD2Qi28円X+ë<7%É31α}‹iY¬>0ëY13⁄4ǝDÅsD12‹i>1ë1円Dǝ¤>2}}ǝVYI'.¡Q#
+5 bytes due to a part I forgot in Zeller's formula (year-1 for months January and February)..
-1 byte thanks to @Grimmy, by changing \$\left\lfloor{\frac{13(m+1)}{5}}\right\rfloor\$ to \$\left\lfloor{\frac{26(m+1)}{10}}\right\rfloor\$ in the code, since 05AB1E has single-byte builtins for both 26 and 10 (being 2 and T respectively), as opposed to the 3 bytes of 13 and 5.
Try it online or Try it online with an emulated self-specified date of 'today'.
$${\displaystyle h=\left(q+\left\lfloor{\frac{13(m+1)}{5}}\right\rfloor+K+\left\lfloor{\frac{K}{4}}\right\rfloor+\left\lfloor{\frac{J}{4}}\right\rfloor-2J\right){\bmod{7}}}$$
Y # Push variable `Y`
` # Push the day, month, and year to the stack
U # Pop and save the year in variable `X`
Ð # Triplicate the month
3‹ # Check if the month is below 3 (Jan. / Feb.),
# resulting in 1 or 0 for truthy/falsey respectively
12* # Multiply this by 12 (either 0 or 12)
+ # And add it to the month
# This first part was to make Jan. / Feb. 13 and 14
> # Month + 1
2* # Multiplied by 26
T÷ # Integer-divided by 10
s3‹ # Check if the month is below 3 again (resulting in 1 / 0)
Xα # Take the absolute difference with the year
© # Store this potentially modified year in the register
т% # mYear modulo-100
D4÷ # mYear modulo-100, integer-divided by 4
®т÷©4÷ # mYear integer-divided by 100, and then integer-divided by 4
®·( # mYear integer-divided by 100, doubled, and then made negative
) # Wrap the entire stack into a list
ć # Extract the head (the counter variable that was also on the stack)
s # Swap so the calculated values above are as list at the top
O # Take the sum of this entire list
7% # And then take modulo-7 to complete the formula,
# resulting in 0 for Saturday, 1 for Sunday, and [2, 6] for [Monday, Friday]
2@ # Check if the day is greater than or equal to 2 (so a working day)
- 136.2k
- 14
- 154
- 394
- 136.2k
- 14
- 154
- 394
- 136.2k
- 14
- 154
- 394
- 136.2k
- 14
- 154
- 394
- 136.2k
- 14
- 154
- 394