How to resolve the algorithm Long year step by step in the Action! programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Long year step by step in the Action! programming language

Table of Contents

Problem Statement

Most years have 52 weeks, some have 53, according to ISO8601.

Write a function which determines if a given year is long (53 weeks) or not, and demonstrate it.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Long year step by step in the Action! programming language

Source code in the action! programming language

BYTE FUNC P(CARD y)
RETURN ((y+(y/4)-(y/100)+(y/400)) MOD 7)

BYTE FUNC IsLongYear(CARD y)
  IF P(y)=4 OR P(y-1)=3 THEN
    RETURN (1)
  FI
RETURN (0)

PROC Main()
  CARD y
  BYTE LMARGIN=$52,oldLMARGIN

  oldLMARGIN=LMARGIN
  LMARGIN=0 ;remove left margin on the screen
  Put(125) PutE() ;clear the screen

  FOR y=1900 TO 2400
  DO
    IF IsLongYear(y) THEN
      PrintC(y) Put(32)
    FI
  OD

  LMARGIN=oldLMARGIN ;restore left margin on the screen
RETURN

  

You may also check:How to resolve the algorithm Host introspection step by step in the F# programming language
You may also check:How to resolve the algorithm Pythagorean quadruples step by step in the Wren programming language
You may also check:How to resolve the algorithm Sailors, coconuts and a monkey problem step by step in the J programming language
You may also check:How to resolve the algorithm Read a configuration file step by step in the Gambas programming language
You may also check:How to resolve the algorithm Table creation/Postal addresses step by step in the Raku programming language