Chinese zodiac: Difference between revisions

m
Add more information to intro; update example to current year.
m (Add more information to intro; update example to current year.)
Line 1:
{{task}}Determine the Chinese zodiac sign and related associations for a given year.
 
Traditionally, the Chinese have counted years using two simultaneouslists cyclesof labels, one of length 10 (the "celestial stems") and one of length 12 (the "terrestrial branches");. theThe combinationlabels resultsdo innot areally repeatinghave 60-yearany pattern.meaning Mappingoutside thetheir branchespositions toin twelvethe traditionaltwo animallists; deitiesthey're resultssimply ina thetraditional well-knownenumeration "Chinese zodiac"device, assigningused eachmuch yearas towe ause givenletters and animalnumbers. ForThey example,were Tuesday,historically Februaryused 1,for 2022months CEand (indays theas commonwell Gregorianas calendar)years, will beginand the lunisolarstems Yearare ofstill thesometimes used for school Tigergrades.
 
Years cycle through both lists concurrently, so that both stem and branch advance each year; if we used Roman letters for the stems and numbers for the branches, consecutive years would be labeled A1, B2, C3, etc. Since the two lists are different lengths, they cycle back to their beginning at different points: after J10 we get A11, and then after B12 we get C1. The result is a repeating 60-year pattern within which each pair of names occurs only once.
The celestial stems have no one-to-one mapping like that of the branches to animals; however, the five pairs of consecutive stems each belong to one of the five traditional Chinese elements (Wood, Fire, Earth, Metal, and Water). Further, one of the two years within each element's governance is associated with <i>yin</i>, the other with <i>yang</i>.
 
Mapping the branches to twelve traditional animal deities results in the well-known "Chinese zodiac", assigning each year to a given animal. For example, Sunday, January 22, 2023 CE (in the common Gregorian calendar) began the lunisolar Year of the Rabbit.
Thus, 2022 is also the yang year of Water. Note that since 12 is an even number, the association between animals and yin/yang doesn't change. Consecutive Years of the Rooster will cycle through the five elements, but will always be yin, despite the apparent conceptual mismatch between the specifically-male English animal name and the female aspect denoted by yin.
 
The celestial stems do not have noa one-to-one mapping like that of the branches to animals; however, the five pairs of consecutive stems are each belongassociated towith one of the five traditional Chinese elements (Wood, Fire, Earth, Metal, and Water). Further, one of the two years within each element's governance is associatedassigned withto <i>yin</i>, the other withto <i>yang</i>.
 
Thus, 2022the Chinese year beginning in 2023 CE is also the yangyin year of Water. Note that sinceSince 12 is an even number, the association between animals and yin/yang doesn't change.; Consecutiveconsecutive Years of the Rooster will cycle through the five elements, but will always be yin, despite the apparent conceptual mismatch between the specifically-male English animal name and the female aspect denoted by yin.
 
;Task: Create a subroutine or program that will return or output the animal, yin/yang association, and element for the lunisolar year that begins in a given CE year.
Line 13 ⟶ 17:
;Requisite information:
* The animal cycle runs in this order: Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, Rooster, Dog, Pig.
* The element cycle runs in this order: Wood, Fire, Earth, Metal, Water.
* Each element gets two consecutive years; a yang followed by a yin.
* The yang year precedes the yin year within each element.
* The current 60-year cycle began in 1984 CE; theany first cyclemultiple of the60 years from that point Commonmay Erabe beganused into 4reckon CEfrom.
 
Thus, 1984year was1 of a cycle is the year of the Wood Rat (yang), 1985 was the year of2 the Wood Ox (yin), and 1986 the year of3 the Fire Tiger (yang);. The year 20222023 - which, as already noted, is the year of the Water TigerRabbit (yangyin) - is the 39th40th year of the current cycle.
 
;Information for optional task:
Line 23 ⟶ 27:
* The twelve terrestrial branches are '''子''' ''zĭ'', '''丑''' ''chŏu'', '''寅''' ''yín'', '''卯''' ''măo'', '''辰''' ''chén'', '''巳''' ''sì'', '''午''' ''wŭ'', '''未''' ''wèi'', '''申''' ''shēn'', '''酉''' ''yŏu'', '''戌''' ''xū'', '''亥''' ''hài''. In ASCII Pinyin, those are "zi3", "chou3", "yin2", "mao3", "chen2", "si4", "wu3", "wei4", "shen1", "you3", "xu1", and "hai4".
 
Therefore 1984 was '''甲子''' (''jiă-zĭ'', or jia3-zi3). 20222023 is '''壬寅癸卯''' (''réngŭi-yínmăo'' or ren2gui3-yin2mao3).
=={{header|11l}}==
{{trans|C++}}
1,481

edits