First Number to Contain Each LetterEnglish numeral calculatorCardinal Numbers in Standard American EnglishFour is the magic numberHow many letters in this word?Integer goes back and forth through timeEfficient countingIs the date alphabetical?
Splitting polygons at narrowest part using R?
What does "se jouer" mean here?
To which airspace does the border of two adjacent airspaces belong to?
Generate points for smooth movement between two given points
Why didn't Thatcher give Hong Kong to Taiwan?
Everyone for non livings
Are there photos of the Apollo LM showing disturbed lunar soil resulting from descent engine exhaust?
Archiving processor does not archive
Why did the VIC-II and SID use 6 µm technology in the era of 3 µm and 1.5 µm?
Too many SOQL Queries when inserting records
Is mathematics truth?
How do you manage to study and have a balance in your life at the same time?
If p-value is exactly 1 (1.0000000), what are the confidence interval limits?
Do I need to get a noble in order to win Splendor?
Is it safe for a student to give negative feedback in student evaluations?
Can a country avoid prosecution for crimes against humanity by denying it happened?
Did Alan Turing's student Robin Gandy assert that Charles Babbage had no notion of a universal computing machine?
Why do old games use flashing as means of showing damage?
Can I sleep overnight at Stansted Airport
Is it possible to observe space debris with Binoculars?
If I have an accident, should I file a claim with my car insurance company?
How to find better food in airports
Count rook moves 1D
What is this red bug infesting some trees in southern Germany?
First Number to Contain Each Letter
English numeral calculatorCardinal Numbers in Standard American EnglishFour is the magic numberHow many letters in this word?Integer goes back and forth through timeEfficient countingIs the date alphabetical?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
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.
code-golf number kolmogorov-complexity
$endgroup$
add a comment |
$begingroup$
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.
code-golf number kolmogorov-complexity
$endgroup$
6
$begingroup$
I'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?
$endgroup$
– caird coinheringaahing
8 hours ago
$begingroup$
didn'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.
$endgroup$
– Jonah
3 hours ago
1
$begingroup$
@Jonah added, thanks for the feedback
$endgroup$
– Stephen
3 hours ago
$begingroup$
You're saying "one bajillion" isn't a real number?
$endgroup$
– Jo King
1 hour ago
$begingroup$
@JoKing what's it's decimal representation? :)
$endgroup$
– Stephen
1 hour ago
add a comment |
$begingroup$
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.
code-golf number kolmogorov-complexity
$endgroup$
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.
code-golf number kolmogorov-complexity
code-golf number kolmogorov-complexity
edited 3 hours ago
Stephen
asked 9 hours ago
StephenStephen
8,0352 gold badges36 silver badges102 bronze badges
8,0352 gold badges36 silver badges102 bronze badges
6
$begingroup$
I'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?
$endgroup$
– caird coinheringaahing
8 hours ago
$begingroup$
didn'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.
$endgroup$
– Jonah
3 hours ago
1
$begingroup$
@Jonah added, thanks for the feedback
$endgroup$
– Stephen
3 hours ago
$begingroup$
You're saying "one bajillion" isn't a real number?
$endgroup$
– Jo King
1 hour ago
$begingroup$
@JoKing what's it's decimal representation? :)
$endgroup$
– Stephen
1 hour ago
add a comment |
6
$begingroup$
I'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?
$endgroup$
– caird coinheringaahing
8 hours ago
$begingroup$
didn'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.
$endgroup$
– Jonah
3 hours ago
1
$begingroup$
@Jonah added, thanks for the feedback
$endgroup$
– Stephen
3 hours ago
$begingroup$
You're saying "one bajillion" isn't a real number?
$endgroup$
– Jo King
1 hour ago
$begingroup$
@JoKing what's it's decimal representation? :)
$endgroup$
– Stephen
1 hour ago
6
6
$begingroup$
I'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?
$endgroup$
– caird coinheringaahing
8 hours ago
$begingroup$
I'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?
$endgroup$
– caird coinheringaahing
8 hours ago
$begingroup$
didn'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.$endgroup$
– Jonah
3 hours ago
$begingroup$
didn'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.$endgroup$
– Jonah
3 hours ago
1
1
$begingroup$
@Jonah added, thanks for the feedback
$endgroup$
– Stephen
3 hours ago
$begingroup$
@Jonah added, thanks for the feedback
$endgroup$
– Stephen
3 hours ago
$begingroup$
You're saying "one bajillion" isn't a real number?
$endgroup$
– Jo King
1 hour ago
$begingroup$
You're saying "one bajillion" isn't a real number?
$endgroup$
– Jo King
1 hour ago
$begingroup$
@JoKing what's it's decimal representation? :)
$endgroup$
– Stephen
1 hour ago
$begingroup$
@JoKing what's it's decimal representation? :)
$endgroup$
– Stephen
1 hour ago
add a comment |
8 Answers
8
active
oldest
votes
$begingroup$
JavaScript (Node.js), 78 bytes
c=>(B=Buffer,n=B('8>P7 $(#% +;! MD &"$%"&4 '[B(c)[0]-97])[0]-53)<0?n+21:10**n
Try it online!
How?
Each value is encoded with a single printable character. We use the ASCII range $[32..52]$ to encode $n-32$ and the range $[53..80]$ to encode $10^n-53$.
$endgroup$
add a comment |
$begingroup$
///, 125 bytes
/://///T/000:d/100:a/d0:m/aT:b/aTT:q/bTT:p/qTTT:c/pT:e/0:f/4:g/8:h/3:i/5:l/11:n/1:o/0:r/0:s/6:t/2:u/4:v/5:w/2:x/6:y/20:z/0/
Try it online!
Input is appended to the end of the code, as per I/O meta. The footer in the above TIO link tests all letters simultaneously, as a single newline-delimited string, but the code also works just fine when inputting a single character.
$endgroup$
add a comment |
$begingroup$
Ruby, 70 bytes
->ni="cib@DHCE@@KfA@xo@FBDEBFT@"[n.ord-65].ord;i>96?10**(i-96):i-64}
Try it online!
$endgroup$
$begingroup$
67 bytes
$endgroup$
– G B
4 hours ago
add a comment |
$begingroup$
Wolfram Language (Mathematica), 50 bytes
Letters b, c, m, p and q are skipped for performance reasons when testing on TIO.
(i=0;While[1>StringCount[IntegerName@i,#],i++];i)&
Try it online!
$endgroup$
add a comment |
$begingroup$
Jelly, 36 bytes
Oị“[@ịẆþĊ`o&÷ḲḞṘḂỊP¥t’b48¤_⁹⁵*ɗ¹>?20
Try it online!
A monadic link taking a lower case letter as its argument and returning an integer. Returns 0 for j and k.
Explanation
O | Convert to code point
ị ¤ | Index into following as a nilad (wraps around):
“[...t’ | - Integer 5370441668223940717846370165240010583188867 (stored base 250)
b48 | - Convert to base 48
ɗ >?20 | If >20, following as a dyad using 20 as right argument:
_⁹ | - Subtract right argument (20)
⁵* | - 10 to the power of this
¹ | Else: leave unchanged (identity function)
$endgroup$
add a comment |
$begingroup$
Retina 0.8.2, 89 bytes
^
$'
T`l`111104835__111011062452620`^.
T`abcmpq`139285
d$
$*0$&$*0$&$*0
d
00
T`lyl`10_
Try it online! Link includes test cases. Explanation:
^
$'
Duplicate the input.
T`l`111104835__111011062452620`^.
Change the first copy to the (first) digit of the relevant result.
T`abcmpq`139285
If the number has a multiple of 3 trailing zeros, get that multiple now.
d$
$*0$&$*0$&$*0
And actually convert it into the relevant number of trailing zeros. (Note that this would simplify to *3*0 in Retina 1.)
d
00
Fix up d.
T`lyl`10_
Fix up l and y and remove any remaining letters.
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 77 bytes
x=>(d[x-='A']&15)*Math.Pow(10,d[x]>>4);var d="1Ʊ! aƁñ"
Try it online!
Each value is encoded as a 9 bit sequence: the first 5 bits are the number of 0's after the number, and the last 4 bits encodes the number with all the zeros trimmed.
Example: 1000 -> 11001
$endgroup$
add a comment |
$begingroup$
Stax, 33 bytes
º░¡µ?Äz*B╥╪╩ΓoΣ4ù↓|♂5%⌡ÿΩ²┼himprove this answer
edited 7 hours ago
answered 8 hours ago
ArnauldArnauld
91.7k7 gold badges108 silver badges373 bronze badges
91.7k7 gold badges108 silver badges373 bronze badges
add a comment
Try it online!
$endgroup$
$begingroup$
67 bytes
$endgroup$
– G B
4 hours ago
add a comment |
$begingroup$
Ruby, 70 bytes
->ni="cib@DHCE@@KfA@xo@FBDEBFT@"[n.ord-65].ord;i>96?10**(i-96):i-64}
Try it online!
$endgroup$
$begingroup$
67 bytes
$endgroup$
– G B
4 hours ago
add a comment |
$begingroup$
Ruby, 70 bytes
->ni="cib@DHCE@@KfA@xo@FBDEBFT@"[n.ord-65].ord;i>96?10**(i-96):i-64}
Try it online!
$endgroup$
Ruby, 70 bytes
->ni="cib@DHCE@@KfA@xo@FBDEBFT@"[n.ord-65].ord;i>96?10**(i-96):i-64}
Try it online!
answered 4 hours ago
Level River StLevel River St
20.8k4 gold badges27 silver badges86 bronze badges
20.8k4 gold badges27 silver badges86 bronze badges
$begingroup$
67 bytes
$endgroup$
– G B
4 hours ago
add a comment |
$begingroup$
67 bytes
$endgroup$
– G B
4 hours ago
$begingroup$
67 bytes
$endgroup$
– G B
4 hours ago
$begingroup$
67 bytes
$endgroup$
– G B
4 hours ago
add a comment |
$begingroup$
Wolfram Language (Mathematica), 50 bytes
Letters b, c, m, p and q are skipped for performance reasons when testing on TIO.
(i=0;While[1>StringCount[IntegerName@i,#],i++];i)&
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 50 bytes
Letters b, c, m, p and q are skipped for performance reasons when testing on TIO.
(i=0;While[1>StringCount[IntegerName@i,#],i++];i)&
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 50 bytes
Letters b, c, m, p and q are skipped for performance reasons when testing on TIO.
(i=0;While[1>StringCount[IntegerName@i,#],i++];i)&
Try it online!
$endgroup$
Wolfram Language (Mathematica), 50 bytes
Letters b, c, m, p and q are skipped for performance reasons when testing on TIO.
(i=0;While[1>StringCount[IntegerName@i,#],i++];i)&
Try it online!
answered 6 hours ago
someonesomeone
1,11010 silver badges26 bronze badges
1,11010 silver badges26 bronze badges
add a comment |
add a comment |
$begingroup$
Jelly, 36 bytes
Oị“[@ịẆþĊ`o&÷ḲḞṘḂỊP¥t’b48¤_⁹⁵*ɗ¹>?20
Try it online!
A monadic link taking a lower case letter as its argument and returning an integer. Returns 0 for j and k.
Explanation
O | Convert to code point
ị ¤ | Index into following as a nilad (wraps around):
“[...t’ | - Integer 5370441668223940717846370165240010583188867 (stored base 250)
b48 | - Convert to base 48
ɗ >?20 | If >20, following as a dyad using 20 as right argument:
_⁹ | - Subtract right argument (20)
⁵* | - 10 to the power of this
¹ | Else: leave unchanged (identity function)
$endgroup$
add a comment |
$begingroup$
Jelly, 36 bytes
Oị“[@ịẆþĊ`o&÷ḲḞṘḂỊP¥t’b48¤_⁹⁵*ɗ¹>?20
Try it online!
A monadic link taking a lower case letter as its argument and returning an integer. Returns 0 for j and k.
Explanation
O | Convert to code point
ị ¤ | Index into following as a nilad (wraps around):
“[...t’ | - Integer 5370441668223940717846370165240010583188867 (stored base 250)
b48 | - Convert to base 48
ɗ >?20 | If >20, following as a dyad using 20 as right argument:
_⁹ | - Subtract right argument (20)
⁵* | - 10 to the power of this
¹ | Else: leave unchanged (identity function)
$endgroup$
add a comment |
$begingroup$
Jelly, 36 bytes
Oị“[@ịẆþĊ`o&÷ḲḞṘḂỊP¥t’b48¤_⁹⁵*ɗ¹>?20
Try it online!
A monadic link taking a lower case letter as its argument and returning an integer. Returns 0 for j and k.
Explanation
O | Convert to code point
ị ¤ | Index into following as a nilad (wraps around):
“[...t’ | - Integer 5370441668223940717846370165240010583188867 (stored base 250)
b48 | - Convert to base 48
ɗ >?20 | If >20, following as a dyad using 20 as right argument:
_⁹ | - Subtract right argument (20)
⁵* | - 10 to the power of this
¹ | Else: leave unchanged (identity function)
$endgroup$
Jelly, 36 bytes
Oị“[@ịẆþĊ`o&÷ḲḞṘḂỊP¥t’b48¤_⁹⁵*ɗ¹>?20
Try it online!
A monadic link taking a lower case letter as its argument and returning an integer. Returns 0 for j and k.
Explanation
O | Convert to code point
ị ¤ | Index into following as a nilad (wraps around):
“[...t’ | - Integer 5370441668223940717846370165240010583188867 (stored base 250)
b48 | - Convert to base 48
ɗ >?20 | If >20, following as a dyad using 20 as right argument:
_⁹ | - Subtract right argument (20)
⁵* | - 10 to the power of this
¹ | Else: leave unchanged (identity function)
edited 4 hours ago
answered 6 hours ago
Nick KennedyNick Kennedy
6,4171 gold badge9 silver badges15 bronze badges
6,4171 gold badge9 silver badges15 bronze badges
add a comment |
add a comment |
$begingroup$
Retina 0.8.2, 89 bytes
^
$'
T`l`111104835__111011062452620`^.
T`abcmpq`139285
d$
$*0$&$*0$&$*0
d
00
T`lyl`10_
Try it online! Link includes test cases. Explanation:
^
$'
Duplicate the input.
T`l`111104835__111011062452620`^.
Change the first copy to the (first) digit of the relevant result.
T`abcmpq`139285
If the number has a multiple of 3 trailing zeros, get that multiple now.
d$
$*0$&$*0$&$*0
And actually convert it into the relevant number of trailing zeros. (Note that this would simplify to *3*0 in Retina 1.)
d
00
Fix up d.
T`lyl`10_
Fix up l and y and remove any remaining letters.
$endgroup$
add a comment |
$begingroup$
Retina 0.8.2, 89 bytes
^
$'
T`l`111104835__111011062452620`^.
T`abcmpq`139285
d$
$*0$&$*0$&$*0
d
00
T`lyl`10_
Try it online! Link includes test cases. Explanation:
^
$'
Duplicate the input.
T`l`111104835__111011062452620`^.
Change the first copy to the (first) digit of the relevant result.
T`abcmpq`139285
If the number has a multiple of 3 trailing zeros, get that multiple now.
d$
$*0$&$*0$&$*0
And actually convert it into the relevant number of trailing zeros. (Note that this would simplify to *3*0 in Retina 1.)
d
00
Fix up d.
T`lyl`10_
Fix up l and y and remove any remaining letters.
$endgroup$
add a comment |
$begingroup$
Retina 0.8.2, 89 bytes
^
$'
T`l`111104835__111011062452620`^.
T`abcmpq`139285
d$
$*0$&$*0$&$*0
d
00
T`lyl`10_
Try it online! Link includes test cases. Explanation:
^
$'
Duplicate the input.
T`l`111104835__111011062452620`^.
Change the first copy to the (first) digit of the relevant result.
T`abcmpq`139285
If the number has a multiple of 3 trailing zeros, get that multiple now.
d$
$*0$&$*0$&$*0
And actually convert it into the relevant number of trailing zeros. (Note that this would simplify to *3*0 in Retina 1.)
d
00
Fix up d.
T`lyl`10_
Fix up l and y and remove any remaining letters.
$endgroup$
Retina 0.8.2, 89 bytes
^
$'
T`l`111104835__111011062452620`^.
T`abcmpq`139285
d$
$*0$&$*0$&$*0
d
00
T`lyl`10_
Try it online! Link includes test cases. Explanation:
^
$'
Duplicate the input.
T`l`111104835__111011062452620`^.
Change the first copy to the (first) digit of the relevant result.
T`abcmpq`139285
If the number has a multiple of 3 trailing zeros, get that multiple now.
d$
$*0$&$*0$&$*0
And actually convert it into the relevant number of trailing zeros. (Note that this would simplify to *3*0 in Retina 1.)
d
00
Fix up d.
T`lyl`10_
Fix up l and y and remove any remaining letters.
answered 4 hours ago
NeilNeil
88.3k8 gold badges46 silver badges186 bronze badges
88.3k8 gold badges46 silver badges186 bronze badges
add a comment |
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 77 bytes
x=>(d[x-='A']&15)*Math.Pow(10,d[x]>>4);var d="1Ʊ! aƁñ"
Try it online!
Each value is encoded as a 9 bit sequence: the first 5 bits are the number of 0's after the number, and the last 4 bits encodes the number with all the zeros trimmed.
Example: 1000 -> 11001
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 77 bytes
x=>(d[x-='A']&15)*Math.Pow(10,d[x]>>4);var d="1Ʊ! aƁñ"
Try it online!
Each value is encoded as a 9 bit sequence: the first 5 bits are the number of 0's after the number, and the last 4 bits encodes the number with all the zeros trimmed.
Example: 1000 -> 11001
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 77 bytes
x=>(d[x-='A']&15)*Math.Pow(10,d[x]>>4);var d="1Ʊ! aƁñ"
Try it online!
Each value is encoded as a 9 bit sequence: the first 5 bits are the number of 0's after the number, and the last 4 bits encodes the number with all the zeros trimmed.
Example: 1000 -> 11001
$endgroup$
C# (Visual C# Interactive Compiler), 77 bytes
x=>(d[x-='A']&15)*Math.Pow(10,d[x]>>4);var d="1Ʊ! aƁñ"
Try it online!
Each value is encoded as a 9 bit sequence: the first 5 bits are the number of 0's after the number, and the last 4 bits encodes the number with all the zeros trimmed.
Example: 1000 -> 11001
answered 3 hours ago
Embodiment of IgnoranceEmbodiment of Ignorance
5,2161 silver badge30 bronze badges
5,2161 silver badge30 bronze badges
add a comment |
add a comment |
$begingroup$
Stax, 33 bytes
º░¡µ?Äz*B╥╪╩ΓoΣ4ù↓|♂5%⌡ÿΩ²┼h{☻4O└
Run and debug it
Procedure:
- Extract codepoint from input.
- Index into constant array
[3, 5, 7, 9, 11, -6, 1, 0, -24, -15, 0, 6, 2, 4, 5, 2, 6, 20, 0, -3, -9, -27, -2, 0, 4, 8]using codepoint. (with wrap-around) - If the result is negative, negate and raise
10to that power, otherwise leave as-is.
$endgroup$
add a comment |
$begingroup$
Stax, 33 bytes
º░¡µ?Äz*B╥╪╩ΓoΣ4ù↓|♂5%⌡ÿΩ²┼h{☻4O└
Run and debug it
Procedure:
- Extract codepoint from input.
- Index into constant array
[3, 5, 7, 9, 11, -6, 1, 0, -24, -15, 0, 6, 2, 4, 5, 2, 6, 20, 0, -3, -9, -27, -2, 0, 4, 8]using codepoint. (with wrap-around) - If the result is negative, negate and raise
10to that power, otherwise leave as-is.
$endgroup$
add a comment |
$begingroup$
Stax, 33 bytes
º░¡µ?Äz*B╥╪╩ΓoΣ4ù↓|♂5%⌡ÿΩ²┼h{☻4O└
Run and debug it
Procedure:
- Extract codepoint from input.
- Index into constant array
[3, 5, 7, 9, 11, -6, 1, 0, -24, -15, 0, 6, 2, 4, 5, 2, 6, 20, 0, -3, -9, -27, -2, 0, 4, 8]using codepoint. (with wrap-around) - If the result is negative, negate and raise
10to that power, otherwise leave as-is.
$endgroup$
Stax, 33 bytes
º░¡µ?Äz*B╥╪╩ΓoΣ4ù↓|♂5%⌡ÿΩ²┼h{☻4O└
Run and debug it
Procedure:
- Extract codepoint from input.
- Index into constant array
[3, 5, 7, 9, 11, -6, 1, 0, -24, -15, 0, 6, 2, 4, 5, 2, 6, 20, 0, -3, -9, -27, -2, 0, 4, 8]using codepoint. (with wrap-around) - If the result is negative, negate and raise
10to that power, otherwise leave as-is.
answered 3 hours ago
recursiverecursive
8,14615 silver badges32 bronze badges
8,14615 silver badges32 bronze badges
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f191223%2ffirst-number-to-contain-each-letter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
6
$begingroup$
I'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?
$endgroup$
– caird coinheringaahing
8 hours ago
$begingroup$
didn'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.$endgroup$
– Jonah
3 hours ago
1
$begingroup$
@Jonah added, thanks for the feedback
$endgroup$
– Stephen
3 hours ago
$begingroup$
You're saying "one bajillion" isn't a real number?
$endgroup$
– Jo King
1 hour ago
$begingroup$
@JoKing what's it's decimal representation? :)
$endgroup$
– Stephen
1 hour ago