Since the time of the first mythical Yellow Emperor in 2697 BC (the year 0 for the Chinese), the Chinese era presumes a cycle of sixty years. Each year of this sixty years' cycle receives a name that is put together based on cyclic sequences. The ten year cycle of the Heavenly Stem (left table below) combines the symbols yin and yang with the five elements. The twelve year cycle of the Earthly Branch (right table) uses the animals from the Chinese zodiac. In taking the next name from both cycles, a 60 year cycle is obtained in which no duplicates can be found.

index yin/yang element
0 yang wood
1 yin wood
2 yang fire
3 yin fire
4 yang earth
5 yin earth
6 yang metal
7 yin metal
8 yang water
9 yin water
index zodiac
0 rat
1 buffalo
2 tiger
3 hare
4 dragon
5 snake
6 horse
7 goat
8 monkey
9 chicken
10 dog
11 pig

The year 2011 from our era, for example, corresponds with the year $$2011 + 2697 - 1 = 4707$$ from the Chinese era. Note that we have to subtract an extra year when converting the years BC from our era to the Chinese era. This is because the year zero doesn't exist in our era. The rest after dividing 4707 by ten is 7, so this year corresponds with the Heavenly Stem yin metal. Analogically, 4707 gives rest 3 after being divided by twelve. This corresponds with the Earthly Branch hare. The year 2011 from our era is called the year yin metal hare by the Chinese.

Assignment

  1. Write a function heavenlyStem to which a whole number between zero and nine should be given as an argument. This number represents an index from the cycle of the Heavenly Stem. The function must print the corresponding name from the Heavenly Stem as a result. Make sure to minimize the number of conditions that need to be tested for function. 

  2. Write a function earthlyBranch to which a whole number between zero and eleven should be given as an argument. This number represents an index from the cycle of the Earthly Branch. The function must print the corresponding name from the cycle of the Earthly Branch as a result. 

  3. Use the functions heavenlyStem and earthlyBranch to write a function chineseYear, to which a year from our era should be given as an argument. The function must print the Chinese name of the year as a result.

Example

>>> heavenlyStem(3)
'yin fire'
>>> earthlyBranch(11)
'pig'
>>> chineseYear(2011)
'yin metal hare'