Five weekends: Difference between revisions

(→‎{{header|Python}}: update to Python > 3.9; PEP 8 and other minor tweaks)
Line 6,267:
2100-October
Total : 201
</pre>
 
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! RPL code
! Comment
|-
|
OVER 3 < -
R→B DUP 4 / OVER 100 / - OVER 400 / + + B→R
{ 0 3 2 5 0 3 5 1 4 6 2 4 } ROT GET + + 7 MOD
≫ ''''DAYoW'''' STO
{} (0,0) 1900 2100 FOR y
1 CF 1 12 '''FOR''' m
'''IF''' { 1 3 5 7 8 10 12 } m POS '''THEN'''
'''IF''' 1 m y '''DAYoW''' 5 == '''THEN'''
'''IF''' DUP RE 5 < OVER RE 195 > OR '''THEN'''
y m R→C ROT SWAP + SWAP '''END'''
1 + 1 SF '''END'''
'''END'''
'''NEXT IF''' 1 FC? '''THEN''' (0,1) + '''END'''
'''NEXT'''
≫ ''''MW5WE'''' STO
|
'''DAYoW''' ''( j mm aaaa -- day )''
if ( m < 3 ) { y -= 1; }
return (y + y/4 - y/100 + y/400
+ t[m-1] + d) % 7 ;
'''MW5WE''' ''( -- {(first)..(last)} (months,years) )''
For each year in range
reset flag
scan long months
if month starts on Fridays
if in first 5 or last 5 ones
store as (yyyy,mm)
increase month counter, set flag
if flag not sent, count the year
|}
{{out}}
<pre>
2: { (1901,3) (1902,8) (1903,5) (1904,1) (1904,7) (2097,3) (2098,8) (2099,5) (2100,1) (2100,10) }
1: (201,29)
</pre>
 
1,150

edits