How to resolve the algorithm Discordian date step by step in the Action! programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Discordian date step by step in the Action! programming language

Table of Contents

Problem Statement

Convert a given date from the   Gregorian calendar   to the   Discordian calendar.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Discordian date step by step in the Action! programming language

Source code in the action! programming language

;;; Discordian date calculation - translation of MAD (via PL/M)

;;; returns the next number from line, the terminator is ignored
;;;         pos holds the position in line and is updated to the
;;;             position of the character following the trailing
;;;             delimiter - if there is one
;;;             pos should be set to 1 on rhe first call
INT FUNC getNumber( CHAR ARRAY line, CARD POINTER pos )
  CARD value, linePos

  linePos = pos^
  value   = 0
  ; skip spaces
  WHILE linePos <= line(0) AND line(linePos) = '  DO linePos ==+ 1 OD
  ; get the number
  WHILE linePos <= line(0) AND line(linePos) >= '0 AND line(linePos) <= '9
  DO
    value   ==* 10
    value   ==+ (line(linePos) - '0)
    linePos ==+ 1
  OD
  pos^ = linePos + 1
RETURN(value)

;;; get a Gregorian date and output it as a Discordian date
PROC Main()

  DEFINE STRING_POINTER = "CARD"

  CARD gMonth, gDay, gYear, gPos
  CARD yrDay, season, day, wkDay
  CHAR ARRAY gLine(256)
  STRING_POINTER ARRAY holy5(5), holy50(5), disday(5), disssn(5)
  INT ARRAY mlengt(13) = [   0   0  31  59  90 120
                           151 181 212 243 273 304 334
                         ]
  holy5 (0) = "MUNG"           holy5 (1) = "MOJO"  holy5 (2) = "SYA"
  holy5 (3) = "ZARA"           holy5 (4) = "MALA"
  holy50(0) = "CHAO"           holy50(1) = "DISCO" holy50(2) = "CONFU"
  holy50(3) = "BURE"           holy50(4) = "AF"
  disday(0) = "SWEETMORN"      disday(1) = "BOOMTIME"
  disday(2) = "PUNGENDAY"      disday(3) = "PRICKLE-PRICKLE"
  disday(4) = "SETTING ORANGE"
  disssn(0) = "CHAOS"          disssn(1) = "DISCORD" disssn(2) = "CONFUSION"
  disssn(3) = "BUREAUCRACY"    disssn(4) = "THE AFTERMATH" 

  ; get the Gregorian date from the keyboard, NB: no validation
  Print("Gregorian date (MM/DD/YYYY)> ")
  InputS(gLine)
  gPos   = 1
  gMonth = getNumber(gLine, @gPos)
  gDay   = getNumber(gLine, @gPos)
  gYear  = getNumber(gLine, @gPos)

  ; convert to Discordian
  IF gMonth = 2 AND gDay = 29 THEN
    Print("SAINT TIB'S DAY IN THE Y.O.L.D. ")PrintC(gYear+1166)
  ELSE
    yrDay  = mlengt(gMonth)+gDay
    season = yrDay/73
    day    = yrDay-season*73
    wkDay  = (yrDay-1) MOD 5
    Print(disday(wkDay) )Print(", DAY ")PrintC(day)Print(" OF ")
    Print(disssn(season))Print(" IN THE Y.O.L.D ")PrintC(gYear+1166)
    IF     day =  5 THEN
      PutE()
      Print("CELEBRATE ")Print(holy5(season))Print("DAY")
    ELSEIF day = 50 THEN
      PutE()
      Print("CELEBRATE ")Print(holy50(season))Print("FLUX")
    FI
  FI
  PutE()

RETURN

  

You may also check:How to resolve the algorithm Active object step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Death Star step by step in the VBScript programming language
You may also check:How to resolve the algorithm Check input device is a terminal step by step in the Tcl programming language
You may also check:How to resolve the algorithm First-class functions step by step in the Racket programming language
You may also check:How to resolve the algorithm Trigonometric functions step by step in the Delphi programming language