Jump to content

Chinese zodiac: Difference between revisions

Added solution for Action!
(Tweak description text and update reference year)
(Added solution for Action!)
Line 134:
1984 is the year of the Wood Rat (Yang). 1/60
2017 is the year of the Fire Rooster (Yin ). 34/60
</pre>
 
=={{header|Action!}}==
<lang Action!>CARD ARRAY animals(12),elements(5),stems(10),branches(12),yinYangs(2)
 
PROC Init()
animals(0)="Rat" animals(1)="Ox"
animals(2)="Tiger" animals(3)="Rabbit"
animals(4)="Dragon" animals(5)="Snake"
animals(6)="Horse" animals(7)="Goat"
animals(8)="Monkey" animals(9)="Rooster"
animals(10)="Dog" animals(11)="Pig"
elements(0)="Wood" elements(1)="Fire"
elements(2)="Earth" elements(3)="Metal"
elements(4)="Water"
stems(0)="jia" stems(1)="yi"
stems(2)="bing" stems(3)="ding"
stems(4)="wu" stems(5)="ji"
stems(6)="geng" stems(7)="xin"
stems(8)="ren" stems(9)="gui"
branches(0)="zi" branches(1)="chou"
branches(2)="yin" branches(3)="mao"
branches(4)="chen" branches(5)="si"
branches(6)="wu" branches(7)="wei"
branches(8)="shen" branches(9)="you"
branches(10)="xu" branches(11)="hai"
yinYangs(0)="Yang" yinYangs(1)="Yin"
RETURN
 
CARD FUNC GetAnimal(INT y)
RETURN (animals((y-4) MOD 12))
 
CARD FUNC GetElement(INT y)
RETURN (elements(((y-4) MOD 10)/2))
 
CARD FUNC GetStem(INT y)
RETURN (stems((y-4) MOD 10))
 
CARD FUNC GetBranch(INT y)
RETURN (branches((y-4) MOD 12))
 
CARD FUNC GetYinYang(INT y)
RETURN (yinYangs(y MOD 2))
 
BYTE FUNC GetCycle(INT y)
RETURN ((y-4) MOD 60+1)
 
PROC Main()
INT ARRAY years=[1935 1938 1968 1972 1976 1984 2017 2021]
CHAR ARRAY s
BYTE i,c
INT y
 
Init()
FOR i=0 TO 7
DO
y=years(i)
PrintI(y) Print(" ")
s=GetStem(y) Print(s) Print("-")
s=GetBranch(y) Print(s) Print(" ")
s=GetElement(y) Print(s) Print(" ")
s=GetAnimal(y) Print(s) Print(" ")
s=GetYinYang(y) Print(s) Print(" ")
c=GetCycle(y) PrintB(c) Print("/60") PutE()
OD
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Chinese_zodiac.png Screenshot from Atari 8-bit computer]
<pre>
1935 yi-hai Wood Pig Yin 12/60
1938 wu-yin Earth Tiger Yang 15/60
1968 wu-shen Earth Monkey Yang 45/60
1972 ren-zi Water Rat Yang 49/60
1976 bing-chen Fire Dragon Yang 53/60
1984 jia-zi Wood Rat Yang 1/60
2017 ding-you Fire Rooster Yin 34/60
2021 xin-chou Metal Ox Yin 38/60
</pre>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.