How to resolve the algorithm Day of the week step by step in the Stata programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Day of the week step by step in the Stata programming language
Table of Contents
Problem Statement
A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
In what years between 2008 and 2121 will the 25th of December be a Sunday? Using any standard date handling libraries of your programming language; compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to y2k type problems.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Day of the week step by step in the Stata programming language
Source code in the stata programming language
clear
sca n=2121-2008+1
set obs `=n'
gen year=2007+_n
list if dow(mdy(12,25,year))==0, noobs sep(0)
+------+
| year |
|------|
| 2011 |
| 2016 |
| 2022 |
| 2033 |
| 2039 |
| 2044 |
| 2050 |
| 2061 |
| 2067 |
| 2072 |
| 2078 |
| 2089 |
| 2095 |
| 2101 |
| 2107 |
| 2112 |
| 2118 |
+------+
year=2008::2121
select(year,dow(mdy(12,25,year)):==0)
You may also check:How to resolve the algorithm 100 doors step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Pseudo-random numbers/Middle-square method step by step in the Lua programming language
You may also check:How to resolve the algorithm Price fraction step by step in the Haskell programming language
You may also check:How to resolve the algorithm Poker hand analyser step by step in the Factor programming language
You may also check:How to resolve the algorithm Stream merge step by step in the Racket programming language