#Excel, 63 bytes
Excel, 63 bytes
=A1&MID("thstndrdth",MIN(9,2*RIGHT(A1)*(MOD(A1-11,100)>2)+1),2)
(MOD(A1-11,100)>2)
returns FALSE
when A1
ends with 11
-13
2*RIGHT(A1)*(MOD(A1-11,100)>2)+1
returns 1
if it's in 11
-13
and 3
,5
,7
,etc. otherwise
MIN(9,~)
changes any returns above 9
into 9
to pull the th
from the string
MID("thstndrdth",MIN(~),2)
pulls out the first th
for inputs ending in 11
-13
, st
for 1
, nd
for 2
, rd
for 3
, and the last th
for anything higher.
=A1&MID(~)
prepends the original number to the ordinal.
Posting as wiki since I am not the author of this. (Source)