[Question]
  [
The Animal-Alphabetical Sequence is an infinite string of letters built accordingly to the following procedure:
1. Start with the letter `A`;
2. Replace each letter with the name of the animal starting with such letter in the table below;
3. Go back to step 2.
For instance, the first four steps of the procedure give:
* `A`
* `ADDAX`
* `ADDAXDINGODINGOADDAXXERUS`
* `ADDAXDINGODINGOADDAXXERUSDINGOINDRINYALAGECKOOTTERDINGOINDRINYALAGECKOOTTERADDAXDINGODINGOADDAXXERUSXERUSEAGLEROBINURIALSQUID`
Note that the string obtained at each step is a prefix of the string obtained at the next step. Hence, the procedure does indeed converge to a well-defined infinite string:
`ADDAXDINGODINGOADDAXXERUSDINGOIND...`
# The Challenge
Write a function that takes as input an integer `n` in the range `[0, 2^31 - 1]` and returns as output the `n`-th letter of the Animal-Alphabetical Sequence.
# Notes
* The first letter is the `0`-th.
* Letters can be uppercase or lowercase.
* It must be possible to run the program in the [Try It Online](https://tio.run) interpreter and get the result in at most 5 minutes.
# Test Cases
```
1511763812 -> M
1603218999 -> I
2049234744 -> X
2060411875 -> K
2147483647 -> D
```
# Table of Animal Names
```
ADDAX
BISON
CAMEL
DINGO
EAGLE
FOSSA
GECKO
HORSE
INDRI
JAMBU
KOALA
LEMUR
MOUSE
NYALA
OTTER
PRAWN
QUAIL
ROBIN
SQUID
TIGER
URIAL
VIXEN
WHALE
XERUS
YAPOK
ZEBRA
```
  
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 83 bytes
```
≔AηＦ↨Ｎ⁵≔§⁺η§⪪”$⌊∧Ｘ;F‖ρ=ＪD θ⊘⊙～'ΣV⦄Ｋ◨｜]≕‖◨⟧TJρ¿¿C´!⁸⁶S/Ｕ¶V×Ｗ⧴a“,=6；‴*Þ↓h!�{≦”⁴⌕αηιηη
```
[Try it online!](https://tio.run/##NY/LTsMwFET3fIWVlS0FCRUjhFjdEBOu6tjBrkW7TNtALAW3ygPx98aIspszmsWZQ9@Oh1M7xAjT5D8CzSDLSc8er95PI6FFO3UUw3mZ1fK570bKcnLHGLmMYcZw7L5pMywT7XPyz/Y8@JlmZQlbtFpBLSSqSkMlhbYWxNNaa2OFKg1CXTgNEkTtjHZW7FLebIQx8KYcoNQFqleHJVapQ5C4FeoFpBDGWWj0OtnyJPXsw5G2v@YskWd/H5rRh5mmFOPqhj@sbvk95/H6a/gB "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
≔Aη
```
Start with `A` at the `0`th index.
```
Ｆ↨Ｎ⁵
```
Input `n`, convert it to base 5 and loop over the digits.
```
≔§⁺η§⪪”...”⁴⌕αηιη
```
Get the current animal from the compressed string of all animal suffixes (excluding `EBRA`) and lookup the appropriate letter from the current digit.
```
η
```
Output the final letter.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 168 bytes
```
n=>[...n.toString(5)].reduce((c,k)=>'DIAIA-EON-OEOYTRUOQIR-HEADSMNG-CRD-AMUATAABUGI-ARPAOEGL-KSR-LUSLEWIIIEA-LUOXNLOE-OEI-AREARNLNDRL-ESK'[Buffer(c)[0]-90+k*25]||c,'A')
```
[Try it online!](https://tio.run/##ZcxPb4IwAAXw@z6FN@hmK@U/B0zqaFhDoVuRzIVwMAjGaWBB9OR3Zyzc2O0lv/fe9/6@v5bd6aeHTXuohtofGn@dI4Qa1Ldp352ao2qBAnXV4VZWqlouz8BfKwEjjEAqEiio@NrKTHwwCd8oCdI4CeGrDCCJM7IlZJOFDBL5TgQNOYxSCXmWcvrJGKNkzGKXcEHHm78WJTLhSSA5pGmk5JtbXVedWoJcK6CnvZyfdat4PMqlQhQwlG1zbS8VurRHtVaxhbFjGy7WAVisVov4aea2ZujY9TxvcjZzXTM93TAd05x8989tzcTYdazJo7njcesatulMHgy/ "JavaScript (Node.js) – Try It Online")
### How?
The lookup string (let's call it `S`) is built as 4 sub-strings of 25 characters as follows:
```
ABCDEFGHIJKLMNOPQRSTUVWXY
-------------------------
DIAIA-EON-OEOYTRUOQIR-HEA  --> 2nd letter of each word
DSMNG-CRD-AMUATAABUGI-ARP  --> 3rd letter of each word
AOEGL-KSR-LUSLEWIIIEA-LUO  --> 4th letter of each word
XNLOE-OEI-AREARNLNDRL-ESK  --> 5th letter of each word
```
Therefore:
```
S[Buffer(c)[0] - 90 + k * 25] // equivalent to S[Buffer(c)[0] - 65 + (k - 1) * 25]
```
is undefined if `k = 0`, in which case we leave `c` unchanged as expected (the first letter of the word that starts with `c` is `c`).
[Answer]
# [Haskell](https://www.haskell.org/), ~~[170](https://codegolf.stackexchange.com/revisions/216562/2)~~ 162 bytes
*Thanks to AZTECCO for helping me index the lookup shorter*
```
f 0='A'
f n|x<-f$div n 5=(x:drop(4*length['B'..x])"DDAXISONAMELINGOAGLEOSSAECKOORSENDRIAMBUOALAEMUROUSEYALATTERRAWNUAILOBINQUIDIGERRIALIXENHALEERUSAPOK")!!mod n 5
```
[Try it online!](https://tio.run/##FY5RC8FQGEDf/YrRaihriheZ@mZf8@XuftzrhuRBzZAZMdqD/z5znk7n6ZwPr@sxy6oqtTzfAaeRWvm3HPdSO7l8rNwa@u1ylDzvj/agmx3zU3HeOYHjuuW@0wpD2JBmCTEKkhFDJJC1BpzOmZVGGSqCODAMAjA2io3Gbe2rFSoFa2mABAckl4ZCiupGIGiDcgYCURkNC563Os3m7Z78T6rb4ZL7j3ehi6edju3JznPd/tCr2Vc/ "Haskell – Try It Online")
This exceeds TIO's output capacity nearly instantly, so I think this is safe on timing. My quick analysis tells me the algorithm should be \$O(n)\$. That is if you input a number of length \$n\$ bits it should take about the \$n\$ time to find the answer.
I'm not the best at golfing data encoding so I think that is where I am losing the most bytes.
This gets a lot easier to read if we just say we have a function `u` which gives the word for a letter. Then it is:
```
f 0='A'
f n=u(f$div n 5)!!mod n 5
```
[Answer]
# [Python ~~3~~ 2](https://docs.python.org/2/), ~~160 159~~ 158 bytes
```
s="ABCDEGHIKLMNOPQRSTUWXYDIAIAEONOEOYTRUOQIRHEADSMNGCRDAMUATAABUGIARPAOEGLKSRLUSLEWIIIEALUOXNLOEOEIAREARNLNDRLESK"
f=lambda n:s[n and s.find(f(n/5))::22][n%5]
```
[Try it online!](https://tio.run/##DctBC4IwFADge79ChGBeCoQIhA7P9rDh3HJzVIgHQ0ZCvSTt0K837983/KbHm@J5Hg8hpEeO2UnkslD6XBpbucv1xgUIQK006ltlnC6FOSFwW6jsaDgUDiqA1GUCzBk0ZjK3Rjor8SKEQJBOX5VcMi4AwSipuJFo83DlD8/2de/agJKxpqClLhg3vqeOeUbbXRQlSRw3Na13zTx8epoCz3oavhOLonn/Bw "Python 2 – Try It Online")
*-1 thanks to @ovs*
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~78~~ 77 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
'aI5вvA…fjvмSD.•13ôºå}Æ ë¾‚pu®×ÌмĀαù·o×#·Îg4™Ā8%+ÚONp:rƒÜ∊₁Œ¿ÝøuÏādûá•4ôøJ‡yè
```
-1 byte thanks to *@Arnauld*.
Output in lowercase.
[Try it online](https://tio.run/##AZMAbP9vc2FiaWX//ydhSTXQsnZB4oCmZmp20LxTRC7igKIxM8O0wrrDpX3DhiDDq8K@4oCacHXCrsOXw4zQvMSAzrHDucK3b8OXI8K3w45nNOKEosSAOCUrw5pPTnA6csaSw5ziiIrigoHFksK/w53DuHXDj8SBZMO7w6HigKI0w7TDuErigKF5w6j//zE1MTE3NjM4MTI) or [verify all test cases](https://tio.run/##AdcAKP9vc2FiaWX/dnk/IiDihpIgIj//J2F5NdCydkHigKZmanbQvFNELuKAojEzw7TCusOlfcOGIMOrwr7igJpwdcKuw5fDjNC8xIDOscO5wrdvw5cjwrfDjmc04oSixIA4JSvDmk9OcDpyxpLDnOKIiuKCgcWSwr/DncO4dcOPxIFkw7vDoeKAojTDtMO4SuKAoXnDqP99LP9bMCwxLDMsMTAsMTUxMTc2MzgxMiwxNjAzMjE4OTk5LDIwNDkyMzQ3NDQsMjA2MDQxMTg3NSwyMTQ3NDgzNjQ3XQ).
**Explanation:**
```
'a             '# Push string "a"
  I             # Push the input-integer
   5в           # Convert it to base-5 as list
     v          # Loop `y` over each digit in this list:
      A         #  Push the lowercase alphabet
       …fjvм    #  Remove the letters 'f', 'j', and 'v'
            S   #  Convert it to a list of characters
             D  #  Duplicate this list
      .•13ôºå}Æ ë¾‚pu®×ÌмĀαù·o×#·Îg4™Ā8%+ÚONp:rƒÜ∊₁Œ¿ÝøuÏādûá•
                #  Push compressed string "ddaxisonamelingoagleeckoorsendrioalaemurouseyalatterrawnuailobinquidigerrialhaleerusapok"
        4ô      #  Split the string into parts of 4 characters
          ø     #  Create pairs with the alphabet-list (the trailing 'z' is ignored)
           J    #  Join each pair together to a single 5-char string
            ‡   #  Transliterate the current character to the animal name 
                #  (again ignoring the trailing 'z')
             yè #  And index digit `y` into this string for the next iteration
                # (after the loop, the resulting character is output implicitly)
```
[See this 05AB1E tip of mine (section *How to compress strings not part of the dictionary?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `.•13ôºå}Æ ë¾‚pu®×ÌмĀαù·o×#·Îg4™Ā8%+ÚONp:rƒÜ∊₁Œ¿ÝøuÏādûá•` is `"ddaxisonamelingoagleeckoorsendrioalaemurouseyalatterrawnuailobinquidigerrialhaleerusapok"`.
[Answer]
# [Perl 5](https://www.perl.org/), 175 bytes
```
sub f{my$n=pop;$_=substr$n?f(1,$n/5):ADDAX,$n%5,1;@_?$_.[DDAXISONAMELINGOAGLE_ECKOORSENDRI_OALAEMUROUSEYALATTERRAWNUAILOBINQUIDIGERRIAL_HALEERUSAPOK=~/_|.{4}/g]->[-65+ord]:$_}
```
[Try it online!](https://tio.run/##Tc/basIwHMfxe5@iSIaW1UN6PlA1W4ML1mZrLXOIBIZVhNmWtsLEucs9wB5xL9LVTrbl6s/387tJGmUvSlnm@2dufdwdQGynSWoBZlclLzIQD9dtKIC4p/Amchw0r@4rRYDWiA0B6y7OiQTUQ1PsEm9M0djFDN9OKPUD7Dk@YRS5CE9Dn4YBfqru2Qz7Pnr0QkRcekO8h5A4ZFw1glx2h1yM/TBA93Riv/fYW/con3qbZWew6KjKdZKtliZgp3KfR9wsygvTnCZZZDXWSdZucNVbQAVCTZV0KHL2gGtNW0vhAmpfEqFuGEYN5BfEvmyIkqzJcg3zf6D2ZQh1Talh8gewWuuSKms1OGfgj7XtDm2wjVMBRK8pb48Asy4ZbJLCXtfI/7Rt3j7Heio0L8R9fXxy59ysVqfGKokjVlQf3cYbq/wG "Perl 5 – Try It Online")
Somewhat ungolfed. Added whitespace and moved dictionary string into variable $animals:
```
sub f {
  $animals='DDAXISONAMELINGOAGLE_ECKOORSENDRI_OALAEMUROUSE'
          .'YALATTERRAWNUAILOBINQUIDIGERRIAL_HALEERUSAPOK';
  my $n=pop;                          #arg
  $_=substr                           #put letter into $_
    $n ? f(1,$n/5) : ADDAX,           #next word is word at n/5 or first word
    $n%5,1;                           #get letter at pos n%5 of word
  @_                                  #if recursed ...
  ?$_.[$animals=~/_|.{4}/g]->[-65+ord]#then return letter + its 4 letters in dict
  :$_                                 #else return just letter
}
```
About runtime: on my "vintage" laptop the five test cases spends about 0.025 sec in total. If I change `$n/5` into `int$n/5` this is reduced to 0.0016 sec (because then it doesn't need to keep dividing by 5 until the decimals disappears, thus far fewer recursions)
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~254~~ ~~234~~ ~~230~~ ~~229~~ ~~228~~ ~~209~~ ~~199~~ 198 bytes
```
string f(int v,int p=-1){var h=v>-p?f(v/5,v%5):"ADDAX";return p<0?h[..1]:h[p]+"DDAXISONAMELINGOAGLEOSSAECKOORSENDRIAMBUOALAEMUROUSEYALATTERRAWNUAILOBINQUIDIGERRIALIXENHALEERUSAPOK"[(h[p]*4-260)..];}
```
[Try it online!](https://tio.run/##dc1Na4NAEAbge3@FCAVtEnV1/Uqahklc7JLVbTWSFMmhBFOFYkSNl9LfbiN4TC/D8M7DO6dmdmqKvm/auii/hLNUlK3QTYdZLWdI/uk@ayFfdpPqRVudpU41p92jKc9F8Dw4iIs6a691KVTP2ipPFQUd53laHSficKUxDyEgjIY@B58RHsdANlvOo5iEXkQhWCccGJAgiXgSk4/bvtuRKIJ9mABlfE3D94R61L9lFBg9kPAVGCFREsMb34qpNDx7wjPd0mRFOS5@@82lbC7fmbKvizZjRZlJZwmZCNmW4SBdlheCqgrBw11maYaOHNd1R0bvMl3Drm5gG@ORHf5hloYRcmxzZNv7DN2aHMPC9si8/g8 "C# (Visual C# Interactive Compiler) – Try It Online")
**How?**
```
char f(int v, int p = -1)
{
    var h = v > -p ? f(v / 5, v % 5) : "ADDAX";
    return p < 0 ? h[..1] : h[p] + "DDAXISONAMELINGOAGLEOSSAECKOORSENDRIAMBUOALAEMUROUSEYALATTERRAWNUAILOBINQUIDIGERRIALIXENHALEERUSAPOK"[(h[p] * 4 - 260)..];
}
```
This version is a complete rewrite of my original solution. Inspired from other submissions, I decided to use a recursive function. The gist is still converting `v` to base 5 and use the digits to point to the correct words. When `v` and `p` are both equal to 0, the conversion is complete, so we take `ADDAX` and stop the recursion.
`Zebra` was removed from the list because it is not reachable.
Updates:
* Saved 20 bytes removing the first letter from each word in the string literal.
* Replacing `do/while` with a `for` loop reduced the size by 4 bytes
* -1 byte using a tuple to assign `b` and `g`
* -1 byte replacing 'A' with 65
* -1 byte replacing `[((h[b] - 65) * 4)..]` with `[(h[b]*4 - 260)..]`
* -10 bytes using a recursive function
* -1 byte replacing `v+p>0` with `v>-p` (thanks to @ceilingcat)
[Answer]
# [Julia 1.0](http://julialang.org/), 153 bytes
```
f(n)=*('A':'Y'...,"DIAIAOEONAOEOYTRUOQIRIHEADSMNGSCRDMAMUATAABUGIXARPAOEGLSKSRBLUSLEWIIIEAELUOXNLOEAOEIUAREARNLNDRLNESK")[n<1||f(n÷5)-'@':25:end][1+n%5]
```
[Try it online!](https://tio.run/##LU3dSsMwGL3PU5SBpNVamjb9xYrfbKhhaarJghujF4IbTEYQV8GLvZcP4IPVDr05nD/Oefs87F/I1zjuXOtVly4GXOI1DoLAn9UcOHSsk2dYL5XpnrjiDwxq3cpG36u6hdbAEmBuGr4C9TgVG6EXWs2F0YI9c84ZMGG6lRQdm1JuQDFQUshaCcn0YuZt7A05nab7n@/Eu8Z3uIyScmtf@w25shdJPw7b43B0KmeDSEJIlsY5iXxE0jCOSF4UhY@ikBZRTDNKzzwNKSF5lkycTF4epzTzUY/Q@8feDgcbuH@LQXXr7P6F542/ "Julia 1.0 – Try It Online")
[Answer]
# PowerShell, 185 182 179 177 174 173 Bytes
-1 byte thanks to mazzy!
```
for($f=[char]65;!($x=$f[$args])){$f=$f|%{,$_+"DDAXISONAMELINGOAGLEOSSAECKOORSENDRIAMBUOALAEMUROUSEYALATTERRAWNUAILOBINQUIDIGERRIALIXENHALEERUSAPOK"[($i=$_%65*4)..($i+3)]}}$x
```
Could probably be shortened, but I got stumped. If 0 can be ignored as an input, you can drop the [char] in [char]65 to save 4 bytes.
]