41
2
Given a single letter from A to Z (except J and K) as input, output the smallest non-negative integer containing that letter in its written form. Assume numbers never contain the word "and", so 101
is "one hundred one", not "one hundred and one". Assume American (short-scale) counting, so one million is 10^6
and one billion is 10^9
.
a 1000 one thousand
b 1000000000 one billion
c 1000000000000000000000000000 one octillion
d 100 one hundred
e 0 zero
f 4 four
g 8 eight
h 3 three
i 5 five
j
k
l 11 eleven
m 1000000 one million
n 1 one
o 0 zero
p 1000000000000000000000000 one septillion
q 1000000000000000 one quadrillion
r 0 zero
s 6 six
t 2 two
u 4 four
v 5 five
w 2 two
x 6 six
y 20 twenty
z 0 zero
J and K are not part of the input specification, so your behavior is undefined for them. Given one of the above letters, output the (decimal) number next to it. You can take input in lowercase or uppercase, but you cannot require that some inputs are lowercase and others uppercase.
This is code-golf, so the shortest answer in bytes wins.
11I'm not quite sure why this challenge has been downvoted so much? As far as I can see, it's clear and on-topic. Sure it's most likely to simply be encoding each letter to its corresponding number, but I don't think that justifies 3 downvotes? – caird coinheringaahing – 2019-09-03T15:39:03.030
1didn't downvote, but fwiw even though it's strictly not required, it would have helped for clarity to list the names of the numbers. it's nothing more than a kolmogoriv-complexity / compression problem, but somehow that's not immediately clear from the description. input domain: a..z. output: defined by this table. actual
##
sections like that would also help. – Jonah – 2019-09-03T20:48:59.4932@Jonah added, thanks for the feedback – Stephen – 2019-09-03T20:56:37.307
11You're saying "one bajillion" isn't a real number? – Jo King – 2019-09-03T22:17:03.377
2@JoKing what's it's decimal representation? :) – Stephen – 2019-09-03T22:35:35.203
1It would also be interesting with any combination of letters. – Eric Duminil – 2019-09-04T03:02:57.290
@EricDuminil feel free to ask a separate question! – Stephen – 2019-09-04T03:03:38.310
1
"Googolpleiji" - J -
– Jonah – 2019-09-04T04:24:15.3833^3^9
. "Killillion" - K -10^(3*10^3000+3)
From here.8I reckon that a StackExchange user who thinks that k can't appear in a number's name is rather lakhing in imagination. – Andrew Grimm – 2019-09-04T05:01:14.827
1@AndrewGrimm well, I don't want Mathematica builtins to be completely useless in a sea of compression answers – Stephen – 2019-09-04T05:03:33.317
1@Jonah, Googolpleiji is not the smallest for j : almost there's Googovij, and for k : Integral-dekapetaseptemdecile from the same page – Nahuel Fouilleul – 2019-09-04T10:41:00.613
I think Googolpleiji and Killillion might be a little bit challenging to output. – James – 2019-09-04T21:16:54.627
For
j
the output could besqrt(-1)
. – rafa11111 – 2019-09-05T00:21:40.837@Jonah "Googovij" (105,413,504) is shorter – Embodiment of Ignorance – 2019-09-05T02:57:04.600
2Integer Sequence A050933 – Paused until further notice. – 2019-09-05T21:25:30.117