# What's the current zodiac?

Display the emoji of the eastern zodiac of given time, according to given country.

The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a repeating 12-year cycle. It is also assigned to hours.

Rules:

1. The country must be given as ISO 3166-1 alpha-3 code. The list is here.

2. The input format must be like this: <ISO code> HH:MM. The input must be a single string. Any input that doesn't fit this format falls in don't care situation.

3. If the given time lies in boundary of the chart given below, you can output either zodiac.

4. As this is a code golf, the shortest code in bytes wins.

The zodiacs:

The zodiacs without specified country are defaults.

• The first zodiac (23:00 – 01:00):

• Rat 🐀 (U+1F400)
• Mouse 🐁 (U+1F401) in Persia (IRN)
• The second zodiac (01:00 – 03:00):

• Ox 🐂 (U+1F402)
• Water Buffalo 🐃 (U+1F403) in Vietnam (VNM)
• Cow 🐄 (U+1F404) in Persia
• The third zodiac (03:00 – 05:00):

• Tiger 🐅 (U+1F405)
• Leopard 🐆 (U+1F406) in Persia
• The fourth zodiac (05:00 – 07:00):

• Rabbit 🐇 (U+1F407)
• Cat 🐈 (U+1F408) in Vietnam
• The fifth zodiac (07:00 – 09:00):

• Dragon 🐉 (U+1F409)
• Crocodile 🐊 (U+1F40A) / Whale 🐋 (U+1F40B) in Persia (you can output either)
• Snail 🐌 (U+1F40C) in Kazakhstan (KAZ)
• The sixth zodiac (09:00 – 11:00):

• Snake 🐍 (U+1F40D)
• The seventh zodiac (11:00 – 13:00):

• Horse 🐎 (U+1F40E)
• The eighth zodiac (13:00 – 15:00):

• Ram 🐏 (U+1F40F)
• Goat 🐐 (U+1F410) in Vietnam
• Sheep 🐑 (U+1F411) in Persia
• The ninth zodiac (15:00 – 17:00):

• Monkey 🐒 (U+1F412)
• The tenth zodiac (17:00 – 19:00):

• Rooster 🐓 (U+1F413)
• Chicken 🐔 (U+1F414) in Persia
• The eleventh zodiac (19:00 – 21:00):

• Dog 🐕 (U+1F415)
• The twelfth zodiac (21:00 – 23:00):

• Pig 🐖 (U+1F416)
• Boar 🐗 (U+1F417) in Japan (JPN)
• Elephant 🐘 (U+1F418) in Thailand (THA)

The code points are from here.

Example:

Given the following input:

KOR 19:42


The output must be:

🐕

• Interesting - I knew these cycled every 12 years. I never heard of the 24 hour cycle. Still, the challenge is clearly specified as it stands. "Correcting" it to 12 years may lead to confusion. Oct 5, 2019 at 10:52
• What's up with Persia having so many different versions? Any specific reasons? Oct 5, 2019 at 18:31
• @cairdcoinheringaahing I'm not an Iranian, so I don't know. Oct 5, 2019 at 23:34
• @cairdcoinheringaahing an old Persian poet and dictionary writer called "Abou Nasr Farahi" or in Persian "ابونصر_فراهی" has a short poem in one of his books, which names those animals in that order in it and thus they are the animals used in Iran for every of those 12 years. He has not been a very famous poet, so not many English resources can be found about him, but I checked his book's text in Persian and the poet was there. Oct 6, 2019 at 3:04
• Oct 6, 2019 at 7:14

# JavaScript (ES6),  168 165 160 157  155 bytes

Saved 4 bytes thanks to @Neil

Returns the crocodile for the 5th zodiac in Persia.

([a,b,c,,d,e])=>String.fromCodePoint(127998-~'00111321211'[k=-~(d+e)%24>>1]+k*2-~(1e12+{IRN:121010020100,VNM:1010001e4,KAZ:3e7,JPN:1,THA:2}[a+b+c]+a)[k+1])


Try it online!

### How?

We define $$\k\$$ as the 0-based index of the zodiac, which can be deduced from the hour $$\h\$$ with:

$$k=\lfloor ((h+1)\bmod 24)/2\rfloor$$

We define $$\x_k\$$ such that the base offset $$\b_k\$$ of the code point for a given zodiac is:

$$b_k = 2k+x_k$$

The final code point is $$\128000+b_k+c_k\$$, where $$\c_k\$$ is the country offset.

This is summarized in the following table:

   k =  |   0 |   1 |   2 |   3 |   4 |   5 |   6 |   7 |   8 |   9 |  10 |  11
--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
b(k)  |  +0 |  +2 |  +5 |  +7 |  +9 | +13 | +14 | +15 | +18 | +19 | +21 | +22
= 2k  |   0 |   2 |   4 |   6 |   8 |  10 |  12 |  14 |  16 |  18 |  20 |  22
+x(k) |   0 |   0 |   1 |   1 |   1 |   3 |   2 |   1 |   2 |   1 |   1 |   0
--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
IRN  |  +1 |  +2 |  +1 |     |  +1 |     |     |  +2 |     |  +1 |     |
VNM  |     |  +1 |     |  +1 |     |     |     |  +1 |     |     |     |
KAZ  |     |     |     |     |  +3 |     |     |     |     |     |     |
JPN  |     |     |     |     |     |     |     |     |     |     |     |  +1
THA  |     |     |     |     |     |     |     |     |     |     |     |  +2


### Commented

( [ a, b, c,               // a,b,c = country code
,                      // the space is ignored
d, e ] ) =>            // d,e = hour (minutes are ignored)
String.fromCodePoint(    // return the character whose code point is:
127998                 //   127998
-~'00111321211'[       //   + 1 + x(k)
k = -~(d + e)        //   where k is defined as:
% 24 >> 1        //     floor(((hour + 1) mod 24) / 2)
] +                    //
k * 2                  //   + 2k
-~(                    //   + 1 + the country offset
1e12 +               //     each pattern being encoded as 10**12
{                    //     + a specific value, leading to:
IRN: 121010020100, //       IRN -> 1121010020100
VNM: 1010001e4,    //       VNM -> 1010100010000
KAZ: 3e7,          //       KAZ -> 1000030000000
JPN: 1,            //       JPN -> 1000000000001
THA: 2             //       THA -> 1000000000002
}[a + b + c]         //     according to the country code
+ a                  //     coerced to a string
)[k + 1]               //   extract the correct offset for this zodiac
)                        //   (gives something NaN-ish for the other countries)

• String.fromCodePoint(128e3+~~ saves 4 bytes.
– Neil
Oct 5, 2019 at 12:30
• @Neil Thanks! :) Oct 5, 2019 at 12:42

þт÷;ò12%Ð•kÄ$ó·;@è₂Èαвλã…7q¼#∍o•5в6ä.•xиʒaàÒ¾Äλ•u3ôIákèsèžy₄*Oç  Try it online! # Charcoal, 73 bytes ℅⁺×¹²⁸φΣＥ⮌…⪪”＆↖∨∧h↘Ｘ⁷↘H⪫³Ｊºρ⁷s,⟲⌈3A‖Cc>χ§₂25:×” ⊕﹪÷⊕Ｉ…η²¦²¦¹²⊕⎇κ÷Ｌι³⌕⪪ι³θ  Try it online! Link is to verbose version of code. Explantion: ℅⁺×¹²⁸φ  0x1F400 = 128,000 (φ is predefined to 1,000). This is added to the sum of the rest of the expression and converted to a character for implicit print. ⊕﹪÷⊕Ｉ…η²¦²¦¹²  The hour is extracted and converted to a zodiac index. …⪪”＆↖∨∧h↘Ｘ⁷↘H⪫³Ｊºρ⁷s,⟲⌈3A‖Cc>χ§₂25:×” ...  The compressed string IRN VNMIRN IRN VNM IRNIRNKAZ VNMIRN IRN JPNTHA is split on spaces and truncated to the length given by that index. ΣＥ⮌...  The array is then reversed, mapped over, and summed. ⊕⎇κ÷Ｌι³⌕⪪ι³θ  For the first element, the string is split into groups of three characters and the country index is taken, otherwise the number of countries is counted. For the first element, the index needs to be converted from 0-indexing to 1-indexing while for the other elements the result needs to be incremented for the default country, so this is done outside of the ternary. # PHP, 185 chars, 263 bytes Thanks to Dannyu NDos for bug fix. fn($i)=>strlen($b=[[🐀,🐁],[🐂,🐄,🐃],[🐅,🐆],[🐇,🐇,🐈],[🐉,🐊,🐉,🐌],🐍,🐎,[🐏,🐑,🐐],🐒,[🐓,🐔],🐕,[🐖,4=>🐗,5=>🐘]][(($t=$i[4].$i[5])%2?$t+1:$t)%24/2])?$b:$b[strpos(____IRN_VNM_KAZ_JPN_THA,substr(\$i,0,3))/4]


Try it online!

Just a simple array mapping, there should be better ways to golf this. Hour part of input time is converted to an even number (0-22) and then it is divided by 2 to get array index 0 to 11 in the mapping. Time periods with special cases are a sub-array with index 0 mapped to default sign and 1-5 mapped to the special sign for IRN, VNM, KAZ, JPN and THA in same order.

# Python 3, 168 bytes

lambda s,a='BA EDC GF HIH KJMJ N O RQP S UT V WWWXYW'.split():chr(ord(a[(int(s[4:6])+1)//2][min('IRNVNMKAZJPNTHA'.find(s[:3])//3,len(a[(int(s[4:6])+1)//2])-1)])+127935)


Try it online!

• 147 bytes if you don't mind switching to Python 3.8. Oct 7, 2019 at 9:06