“As we travel the universe…”
up vote
37
down vote
favorite
You'll be given the name of one of the 20 biggest objects in the Solar System. Your task is to return an approximation of its radius, expressed in kilometers.
This is a code-challenge where your score consists of the length of your code (in bytes) multiplied by a penalty ratio $ge 1$, based on your worst approximation. Therefore, the lowest score wins.
"As we travel the universe" is the last line of the song Planet Caravan by Black Sabbath, also later covered by Pantera.
The Solar System objects
Source: Wikipedia
NB: The rank is given for information only. The input is the name of the object.
n | Object | Radius (km)
----+----------+-------------
1 | Sun | 696342
2 | Jupiter | 69911
3 | Saturn | 58232
4 | Uranus | 25362
5 | Neptune | 24622
6 | Earth | 6371
7 | Venus | 6052
8 | Mars | 3390
9 | Ganymede | 2634
10 | Titan | 2575
11 | Mercury | 2440
12 | Callisto | 2410
13 | Io | 1822
14 | Moon | 1737
15 | Europa | 1561
16 | Triton | 1353
17 | Pluto | 1186
18 | Eris | 1163
19 | Haumea | 816
20 | Titania | 788
Or as copy-paste friendly lists:
'Sun', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Earth', 'Venus', 'Mars', 'Ganymede', 'Titan', 'Mercury', 'Callisto', 'Io', 'Moon', 'Europa', 'Triton', 'Pluto', 'Eris', 'Haumea', 'Titania'
696342, 69911, 58232, 25362, 24622, 6371, 6052, 3390, 2634, 2575, 2440, 2410, 1822, 1737, 1561, 1353, 1186, 1163, 816, 788
Your score
Let $R_n$ be the expected radius of the $n^{th}$ object and let $A_n$ be the answer of your program for this object.
Then your score is defined as:
$$S=leftlceil Ltimesmax_{1le i le20}left({maxleft(frac{A_i}{R_i},frac{R_i}{A_i}right)^2}right)rightrceil$$
where $L$ is the length of your code in bytes.
Example:
If the size of your code is $100$ bytes and your worst approximation is on the Moon with an estimated radius of $1000$ km instead of $1737$ km, then your score would be:
$$S=leftlceil 100times{left(frac{1737}{1000}right)^2}rightrceil=302$$
The lower, the better.
Recommended header for your answer:
Language, 100 bytes, score = 302
You can use this script to compute your score (first line = code length, next 20 lines = your outputs, from Sun to Titania).
Rules
- You may take the name of the object in either full lowercase, full uppercase or exactly as described above (title case). Other mixed cases are not allowed.
- The input is guaranteed to be one of the 20 possible names.
- You may return either integers or floats. In both cases, the penalty must be computed directly with these values (not rounded values in case of floats).
- You must return positive values.
- Empty programs are not allowed.
code-challenge approximation
add a comment |
up vote
37
down vote
favorite
You'll be given the name of one of the 20 biggest objects in the Solar System. Your task is to return an approximation of its radius, expressed in kilometers.
This is a code-challenge where your score consists of the length of your code (in bytes) multiplied by a penalty ratio $ge 1$, based on your worst approximation. Therefore, the lowest score wins.
"As we travel the universe" is the last line of the song Planet Caravan by Black Sabbath, also later covered by Pantera.
The Solar System objects
Source: Wikipedia
NB: The rank is given for information only. The input is the name of the object.
n | Object | Radius (km)
----+----------+-------------
1 | Sun | 696342
2 | Jupiter | 69911
3 | Saturn | 58232
4 | Uranus | 25362
5 | Neptune | 24622
6 | Earth | 6371
7 | Venus | 6052
8 | Mars | 3390
9 | Ganymede | 2634
10 | Titan | 2575
11 | Mercury | 2440
12 | Callisto | 2410
13 | Io | 1822
14 | Moon | 1737
15 | Europa | 1561
16 | Triton | 1353
17 | Pluto | 1186
18 | Eris | 1163
19 | Haumea | 816
20 | Titania | 788
Or as copy-paste friendly lists:
'Sun', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Earth', 'Venus', 'Mars', 'Ganymede', 'Titan', 'Mercury', 'Callisto', 'Io', 'Moon', 'Europa', 'Triton', 'Pluto', 'Eris', 'Haumea', 'Titania'
696342, 69911, 58232, 25362, 24622, 6371, 6052, 3390, 2634, 2575, 2440, 2410, 1822, 1737, 1561, 1353, 1186, 1163, 816, 788
Your score
Let $R_n$ be the expected radius of the $n^{th}$ object and let $A_n$ be the answer of your program for this object.
Then your score is defined as:
$$S=leftlceil Ltimesmax_{1le i le20}left({maxleft(frac{A_i}{R_i},frac{R_i}{A_i}right)^2}right)rightrceil$$
where $L$ is the length of your code in bytes.
Example:
If the size of your code is $100$ bytes and your worst approximation is on the Moon with an estimated radius of $1000$ km instead of $1737$ km, then your score would be:
$$S=leftlceil 100times{left(frac{1737}{1000}right)^2}rightrceil=302$$
The lower, the better.
Recommended header for your answer:
Language, 100 bytes, score = 302
You can use this script to compute your score (first line = code length, next 20 lines = your outputs, from Sun to Titania).
Rules
- You may take the name of the object in either full lowercase, full uppercase or exactly as described above (title case). Other mixed cases are not allowed.
- The input is guaranteed to be one of the 20 possible names.
- You may return either integers or floats. In both cases, the penalty must be computed directly with these values (not rounded values in case of floats).
- You must return positive values.
- Empty programs are not allowed.
code-challenge approximation
1
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
yesterday
I see the scoring has been changed to the power of 2 for the diff? In that case my 100-byte exact answer is shorter than my 70-byte approximation (which scored 91 before, but now 117..)
– Kevin Cruijssen
yesterday
@KevinCruijssen The idea behind that was to prevent extremely short answers (basically returning 1 or 2 constants) to be penalized by a reasonable factor and potentially win against more sophisticated ones.
– Arnauld
yesterday
I approve of the square in the scoring function. My previous best result was a score of 60 using 2 bytes to get7512
for all test cases. I'll see if I dive into creating a MathGolf solution anytime soon, but it'll be hard to beat 05AB1E.
– maxb
17 hours ago
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
16 hours ago
add a comment |
up vote
37
down vote
favorite
up vote
37
down vote
favorite
You'll be given the name of one of the 20 biggest objects in the Solar System. Your task is to return an approximation of its radius, expressed in kilometers.
This is a code-challenge where your score consists of the length of your code (in bytes) multiplied by a penalty ratio $ge 1$, based on your worst approximation. Therefore, the lowest score wins.
"As we travel the universe" is the last line of the song Planet Caravan by Black Sabbath, also later covered by Pantera.
The Solar System objects
Source: Wikipedia
NB: The rank is given for information only. The input is the name of the object.
n | Object | Radius (km)
----+----------+-------------
1 | Sun | 696342
2 | Jupiter | 69911
3 | Saturn | 58232
4 | Uranus | 25362
5 | Neptune | 24622
6 | Earth | 6371
7 | Venus | 6052
8 | Mars | 3390
9 | Ganymede | 2634
10 | Titan | 2575
11 | Mercury | 2440
12 | Callisto | 2410
13 | Io | 1822
14 | Moon | 1737
15 | Europa | 1561
16 | Triton | 1353
17 | Pluto | 1186
18 | Eris | 1163
19 | Haumea | 816
20 | Titania | 788
Or as copy-paste friendly lists:
'Sun', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Earth', 'Venus', 'Mars', 'Ganymede', 'Titan', 'Mercury', 'Callisto', 'Io', 'Moon', 'Europa', 'Triton', 'Pluto', 'Eris', 'Haumea', 'Titania'
696342, 69911, 58232, 25362, 24622, 6371, 6052, 3390, 2634, 2575, 2440, 2410, 1822, 1737, 1561, 1353, 1186, 1163, 816, 788
Your score
Let $R_n$ be the expected radius of the $n^{th}$ object and let $A_n$ be the answer of your program for this object.
Then your score is defined as:
$$S=leftlceil Ltimesmax_{1le i le20}left({maxleft(frac{A_i}{R_i},frac{R_i}{A_i}right)^2}right)rightrceil$$
where $L$ is the length of your code in bytes.
Example:
If the size of your code is $100$ bytes and your worst approximation is on the Moon with an estimated radius of $1000$ km instead of $1737$ km, then your score would be:
$$S=leftlceil 100times{left(frac{1737}{1000}right)^2}rightrceil=302$$
The lower, the better.
Recommended header for your answer:
Language, 100 bytes, score = 302
You can use this script to compute your score (first line = code length, next 20 lines = your outputs, from Sun to Titania).
Rules
- You may take the name of the object in either full lowercase, full uppercase or exactly as described above (title case). Other mixed cases are not allowed.
- The input is guaranteed to be one of the 20 possible names.
- You may return either integers or floats. In both cases, the penalty must be computed directly with these values (not rounded values in case of floats).
- You must return positive values.
- Empty programs are not allowed.
code-challenge approximation
You'll be given the name of one of the 20 biggest objects in the Solar System. Your task is to return an approximation of its radius, expressed in kilometers.
This is a code-challenge where your score consists of the length of your code (in bytes) multiplied by a penalty ratio $ge 1$, based on your worst approximation. Therefore, the lowest score wins.
"As we travel the universe" is the last line of the song Planet Caravan by Black Sabbath, also later covered by Pantera.
The Solar System objects
Source: Wikipedia
NB: The rank is given for information only. The input is the name of the object.
n | Object | Radius (km)
----+----------+-------------
1 | Sun | 696342
2 | Jupiter | 69911
3 | Saturn | 58232
4 | Uranus | 25362
5 | Neptune | 24622
6 | Earth | 6371
7 | Venus | 6052
8 | Mars | 3390
9 | Ganymede | 2634
10 | Titan | 2575
11 | Mercury | 2440
12 | Callisto | 2410
13 | Io | 1822
14 | Moon | 1737
15 | Europa | 1561
16 | Triton | 1353
17 | Pluto | 1186
18 | Eris | 1163
19 | Haumea | 816
20 | Titania | 788
Or as copy-paste friendly lists:
'Sun', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Earth', 'Venus', 'Mars', 'Ganymede', 'Titan', 'Mercury', 'Callisto', 'Io', 'Moon', 'Europa', 'Triton', 'Pluto', 'Eris', 'Haumea', 'Titania'
696342, 69911, 58232, 25362, 24622, 6371, 6052, 3390, 2634, 2575, 2440, 2410, 1822, 1737, 1561, 1353, 1186, 1163, 816, 788
Your score
Let $R_n$ be the expected radius of the $n^{th}$ object and let $A_n$ be the answer of your program for this object.
Then your score is defined as:
$$S=leftlceil Ltimesmax_{1le i le20}left({maxleft(frac{A_i}{R_i},frac{R_i}{A_i}right)^2}right)rightrceil$$
where $L$ is the length of your code in bytes.
Example:
If the size of your code is $100$ bytes and your worst approximation is on the Moon with an estimated radius of $1000$ km instead of $1737$ km, then your score would be:
$$S=leftlceil 100times{left(frac{1737}{1000}right)^2}rightrceil=302$$
The lower, the better.
Recommended header for your answer:
Language, 100 bytes, score = 302
You can use this script to compute your score (first line = code length, next 20 lines = your outputs, from Sun to Titania).
Rules
- You may take the name of the object in either full lowercase, full uppercase or exactly as described above (title case). Other mixed cases are not allowed.
- The input is guaranteed to be one of the 20 possible names.
- You may return either integers or floats. In both cases, the penalty must be computed directly with these values (not rounded values in case of floats).
- You must return positive values.
- Empty programs are not allowed.
code-challenge approximation
code-challenge approximation
edited 14 hours ago
asked yesterday
Arnauld
70.6k688298
70.6k688298
1
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
yesterday
I see the scoring has been changed to the power of 2 for the diff? In that case my 100-byte exact answer is shorter than my 70-byte approximation (which scored 91 before, but now 117..)
– Kevin Cruijssen
yesterday
@KevinCruijssen The idea behind that was to prevent extremely short answers (basically returning 1 or 2 constants) to be penalized by a reasonable factor and potentially win against more sophisticated ones.
– Arnauld
yesterday
I approve of the square in the scoring function. My previous best result was a score of 60 using 2 bytes to get7512
for all test cases. I'll see if I dive into creating a MathGolf solution anytime soon, but it'll be hard to beat 05AB1E.
– maxb
17 hours ago
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
16 hours ago
add a comment |
1
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
yesterday
I see the scoring has been changed to the power of 2 for the diff? In that case my 100-byte exact answer is shorter than my 70-byte approximation (which scored 91 before, but now 117..)
– Kevin Cruijssen
yesterday
@KevinCruijssen The idea behind that was to prevent extremely short answers (basically returning 1 or 2 constants) to be penalized by a reasonable factor and potentially win against more sophisticated ones.
– Arnauld
yesterday
I approve of the square in the scoring function. My previous best result was a score of 60 using 2 bytes to get7512
for all test cases. I'll see if I dive into creating a MathGolf solution anytime soon, but it'll be hard to beat 05AB1E.
– maxb
17 hours ago
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
16 hours ago
1
1
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
yesterday
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
yesterday
I see the scoring has been changed to the power of 2 for the diff? In that case my 100-byte exact answer is shorter than my 70-byte approximation (which scored 91 before, but now 117..)
– Kevin Cruijssen
yesterday
I see the scoring has been changed to the power of 2 for the diff? In that case my 100-byte exact answer is shorter than my 70-byte approximation (which scored 91 before, but now 117..)
– Kevin Cruijssen
yesterday
@KevinCruijssen The idea behind that was to prevent extremely short answers (basically returning 1 or 2 constants) to be penalized by a reasonable factor and potentially win against more sophisticated ones.
– Arnauld
yesterday
@KevinCruijssen The idea behind that was to prevent extremely short answers (basically returning 1 or 2 constants) to be penalized by a reasonable factor and potentially win against more sophisticated ones.
– Arnauld
yesterday
I approve of the square in the scoring function. My previous best result was a score of 60 using 2 bytes to get
7512
for all test cases. I'll see if I dive into creating a MathGolf solution anytime soon, but it'll be hard to beat 05AB1E.– maxb
17 hours ago
I approve of the square in the scoring function. My previous best result was a score of 60 using 2 bytes to get
7512
for all test cases. I'll see if I dive into creating a MathGolf solution anytime soon, but it'll be hard to beat 05AB1E.– maxb
17 hours ago
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
16 hours ago
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
16 hours ago
add a comment |
15 Answers
15
active
oldest
votes
up vote
21
down vote
PowerShell, 3 bytes, score 3637
2e4
Try it online!
Very naive, boring, implementation; just returns 20000
no matter the input. Experimentation with things like special-casing the sun or using floating-point values instead of 2
all resulted in worse scores because the length of code increased enough to offset any size-comparison gains.
2
That's all you need to know about KPI :)
– mazzy
yesterday
6
Why is this getting so many votes?!
– Shaggy
yesterday
8
@Shaggy I'm confused about that as well.. :S It's by far the laziest and highest scoring answer (don't take it personal AdmBorkBork, but I think the Jelly and Java answers deserve the upvotes a lot more). People probably only see the 3 bytes part (or think higher score is better than lower) and ignore everything else. xD In Arnauld's original challenge description in the Sandbox, this answer wouldn't even have been possible, since it allowed a maximum error percentage of 95% for each I/O. Ah well. Enjoy the free rep AdmBorkBork. ;)
– Kevin Cruijssen
18 hours ago
2
@Elcan Or more precisely, it denotes that the rating system is not flawed, given that the resulting score is so high.
– Arnauld
15 hours ago
4
People upvote on PPCG for all sorts of reasons, not just because of raw score (see my huge Minecraft redstone answer for example). I upvoted this answer because it is a clear, simple example of the far end of the spectrum of strategy (the spectrum between "return exact values" vs "save bytes to return an approximation and take the penalty").
– BradC
11 hours ago
|
show 6 more comments
up vote
15
down vote
Jelly, 34 bytes, score = 37
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1*
Input is in uppercase, output is the power of 1.1 with the least error.
Try it online!
How it works
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1* Main link. Argument: s (string)
O Ordinal; map the char in s to their code points.
"ERIS" -> [69,82,73,83]
Ḍ Undecimal; treat the result as an array of digits
in base 10 and convert it to integer.
[69,82,73,83] -> 69000+8200+730+83 = 78013
“⁸|5/!‘ Literal; yield [136, 124, 53, 47, 33].
%ƒ Fold the array by modulus, using the computed
integer as initial value.
78013 -> 78013%136%124%53%47%33 = 32
“RNFLOJMjs⁽u[USJ‘ Literal; yield [82, 78, 70, 76, 79, 74, 77, ...
106, 115, 141, 92, 117, 91, 85, 83, 74].
ị Retrieve the element from the array to the right,
at the index to the left.
Indexing is 1-based and modular.
32 = 16 (mod 16) -> 'J' = 74
1.1* Raise 1.1 to the computed power.
74 = 1.1**74 = 1156.268519450066
Would a "salt with given string, hash, and convert to integer" builtin be useful in Jelly? Or perhaps one that also is modular in case you're not just indexing into an array?
– lirtosiast
23 hours ago
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
14 hours ago
er, "then take the result mod n".
– lirtosiast
3 hours ago
add a comment |
up vote
13
down vote
Java (JDK), 90 bytes, score = 97
s->("ýCĄ (ᬺ!˂Fɍ".charAt(s.substring(2).chars().sum()%96%49%25)-7)*100
Try it online!
- This entry uses both undisplayable and multi-byte Unicode characters (but Java accepts them nevertheless). Check the TIO for the accurate code.
- The input must be title-case.
- This code rounds the values to the best multiple-of-100 (sometimes up, sometimes down) so that the last two digits can be skipped when encoded, and the value can then be approximated by multiplying by 100.
- This entry uses various hashes to fit a 25 codepoints string (shortest string I could find).
Credits
- -48 score (-45 bytes) thanks to Kevin Cruijssen by encoding the radiuses (divided by 100) directly in a
String
instead of hardcoding them in an explicitint
array..
2
96 bytes & 103 score with the same output.
– Kevin Cruijssen
yesterday
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
yesterday
Glad I could help, and nice answer! :) PS: As for why I added the(...-7)
: The unprintable character(char)0
is empty so I had to add something. I first tried9
and8
being single digits, but9
gave of course tabs, requiring multiplet
(2 bytes each), and8
gave an error about an unescaped character used.
– Kevin Cruijssen
yesterday
@KevinCruijssen To be honest, I tried for a few hours yesterday to get better values by expanding your multiplication into*100-700
and playing with the values-as-string and those two numbers, but those are the best, actually, Some values can decrease the byte count, but then the score stays the same. So random pinpointing made (one of) the best case ;)
– Olivier Grégoire
17 hours ago
Talk about undisplayable! This entry really weirds out my Firefox to the point that I can't actually read the rest of the page properly :-(
– Neil
17 hours ago
|
show 2 more comments
up vote
8
down vote
Wolfram Language 114 103 97 88 86 83 bytes. score = 114 103 97 89 87 84 points
#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/."NotAvailable"->816&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 2 more thanks to user202729
.
Although Mathematica can fetch solar system data (as well as much additional astronomical data), some minor tweaks are needed, as explained below.
Interpreter[#,"AstronomicalObject"]&
will return the entity (i.e. the machine computable object) associated with the term represented by #
.
EntityValue[AstronomicalObject,"Radius"]
returns the radius, in miles, of the entity.
"Haumea" returns the value, "NotAvailable", which is replaced by 816.
Multiplication of the radius by 1.61
converts from miles to km. Decimal values, rather than integers, account for much less than 1% error, even in the most extreme case.
[[1]]
returns the magnitude without the unit, km. This was later changed to #&@@
, yielding the same result.
Another wolfram built in. Just like detecting downgoats
– OganM
3 hours ago
I would've answered this but I don't know the wolfram language lol
– Quintec
2 hours ago
add a comment |
up vote
7
down vote
Python 3, score 95, 95 bytes
lambda n:ord("ؙҢਏ𑄗ാᣣ४ঈ挒ឤ?̰ҋ??ۉՉ怮ܞ̔"[int(n,35)%87%52%24-1])
Try it online!
Python 3, score 133, 133 bytes
lambda n:int(f'00e0{10**18+10**6}10x1h2411j4?00??811i1207wazxmwuvko?mw??xc1ze1ldyujz6zysi4?ob??k9lym6w'[int(n,35)%87%52%24-1::23],36)
Try it online!
add a comment |
up vote
4
down vote
05AB1E, score 100 66 60 (100 61 56 bytes)
•1∞²îc|I‰∍T‡sÇ3¡ò½в…»Ë•§•1ë£ñƒq£û¿’…•S£y¦¦ÇO96%49%25%èт*
Port of @OlivierGrégoire's Java answer, so if you like this first answer, make sure to upvote him as well!
Input in titlecase.
Verify all test cases.
05AB1E, score 100 (100 bytes)
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•§•3«8¹ØмS7Ç•S£.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•3ôI2£Iθ«kè
Input in full lowercase. Outputs the exact radius, so no penalty is added.
Verify all test cases.
Explanation:
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•
# Compressed integer 696342699115823225362246226371605233902634257524402410182217371561135311861163816788
§ # Casted to string (bug, should have been implicitly..)
•3«8¹ØмS7Ç• # Compressed integer 65555444444444444433
S # Converted to a list of digits: [6,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3]
£ # The first integer is split into parts of that size: ["696342","69911","58232","25362","24622","6371","6052","3390","2634","2575","2440","2410","1822","1737","1561","1353","1186","1163","816","788"]
.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•
# Compressed string "sunjursanursneeeahvesmasgaetinmeycaoioomoneuatrnploershaatia"
3ô # Split into parts of size 3: ["sun","jur","san","urs","nee","eah","ves","mas","gae","tin","mey","cao","ioo","mon","eua","trn","plo","ers","haa","tia"]
I2£ # The first two characters of the input
Iθ # The last character of the input
« # Merged together
k # Get the index of this string in the list of strings
è # And use that index to index into the list of integers
# (and output the result implicitly)
See this 05AB1E tip of mine (sections How to compress large integers? and How to compress strings not part of the dictionary?) to understand how the compression used works.
I did create a 70-bytes alternative which would map sun to 600,000
; [jupiter,saturn] to 60,000
; [uranus,neptune] to 30,000
; [earth,venus] to 6,000
; [mars,ganymede,titan,mercury,callisto] to 3,000
; [io,moon,europa,triton,pluto,eris] to 1,500
; and [haumea;titania] to 750
. Unfortunately that got a score of 117. I will see if I can get below 100 with an alternative approach later.
1
I found a better hash that use a 25-chars string instead of a 30-chars one. Check my Java answer if you want to update this answer ;)
– Olivier Grégoire
16 hours ago
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
16 hours ago
add a comment |
up vote
4
down vote
Mathematica, 57 bytes, score = 62 58
-4 bytes/score thanks to lirtosiast!
#&@@WolframAlpha[#<>" size km","Result"]]/._Missing->816&
Just does a Wolfram Alpha lookup for the mean radius.
@lirtosiast Thanks!
– LegionMammal978
15 hours ago
add a comment |
up vote
4
down vote
Powershell, 150 bytes, score 163
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
Test script:
$f = {
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
}
$penalty = @(
,("Sun" , 696342)
,("Jupiter" , 69911)
,("Saturn" , 58232)
,("Uranus" , 25362)
,("Neptune" , 24622)
,("Earth" , 6371)
,("Venus" , 6052)
,("Mars" , 3390)
,("Ganymede" , 2634)
,("Titan" , 2575)
,("Mercury" , 2440)
,("Callisto" , 2410)
,("Io" , 1822)
,("Moon" , 1737)
,("Europa" , 1561)
,("Triton" , 1353)
,("Pluto" , 1186)
,("Eris" , 1163)
,("Haumea" , 816)
,("Titania" , 788)
) | % {
$s,$expected = $_
$result = &$f $s
$ratio = [Math]::Max($result/$expected, $expected/$result)
$ratio*$ratio
}
$scriptLength = $f.ToString().Length - 2 # -4 if CRLF mode
$penaltyMax = ($penalty|Measure-Object -Maximum).Maximum
$score = $scriptLength * $penaltyMax
"$score = $scriptLength * $penaltyMax"
Output:
162.113324228916 = 150 * 1.08075549485944
Explanation:
- Names contain letters only, radiuses contain digits and dots. So we can write all the data in a data string and perform a regexp search.
- The script searches for all substrings from left to right and takes the last result found.
- The input must be title-case to reduce the data string.
- The
end of line mode
is LF only.
Example:
Titania Triton Titan
-------------- ------------- -------------
T -> 1.3 T -> 1.3 T -> 1.3
Ti -> 2.5 Tr -> Ti -> 2.5
Tit -> Tri -> Tit ->
Tita -> Trit -> Tita ->
Titan -> Triton -> Titan ->
Titani -> .8
Titania ->
Result is .8 Result is 1.3 Result is 2.5
Powershell, 178 bytes, score 178
($args|% t*y|?{'Su696342J69911S58232U25362N24622Ea6371V6052Ma3390G2634Ti2575Me2440C2410I1822M1737Eu1561T1353P1186E1163H816Titani788'-cmatch"$(($y+=$_))(d+)"}|%{+$Matches.1})[-1]
add a comment |
up vote
3
down vote
Japt, 86 bytes, score = 94
g5 ¥'i?788:[7*A³7*L6*LG²G²IIÉHÄDÑDÑCÑCÑGÄÄGÄGECC8]g`suj«a¨Ì¼và@ã/eÖô¶e©rp¤r`bU¯2)z)*L
Try it for all inputs, Calculate the score, or Check the highest error
Very similar to Olivier's original answer. Input is all lowercase.
After various improvements to the output values, the current highest error is Venus at just over 4%.
Explanation now that things are a bit more stable:
¤¥`Éa`? :If the fifth character of the input is 'i':
788 : Output 788.
: :Otherwise:
[...] : From the array representing radii
g : Get the value at the index:
`...` : In the string representing names
b : Find the first index where this string appears:
U¯2) : The first two characters of the input
z) : And divide it by two
*L : Multiply that value by 100
The string for the names is sujusaurneeavemagatimecaiomoeutrplerha
compressed using Japt's built-in compression. The numbers representing the radii are calculated like so:
My value | Actual value
---------+-------------
7 * 10 ^ 3 = 7000 * 100 = 700000 | 696342
7 * 100 = 700 * 100 = 70000 | 69911
6 * 100 = 600 * 100 = 60000 | 58232
16 * 16 = 256 * 100 = 25600 | 25362
16 * 16 = 256 * 100 = 25600 | 24622
64 = 64 * 100 = 6400 | 6371
64 - 1 = 63 * 100 = 6300 | 6052
32 + 1 = 33 * 100 = 3300 | 3390
13 * 2 = 26 * 100 = 2600 | 2634
13 * 2 = 26 * 100 = 2600 | 2575
12 * 2 = 24 * 100 = 2400 | 2440
12 * 2 = 24 * 100 = 2400 | 2410
16 + 1 + 1 = 18 * 100 = 1800 | 1822
16 + 1 = 17 * 100 = 1700 | 1737
16 = 16 * 100 = 1600 | 1561
14 = 14 * 100 = 1400 | 1353
12 = 12 * 100 = 1200 | 1186
12 = 12 * 100 = 1200 | 1163
8 = 8 * 100 = 800 | 816
788 = 788 | 788
@Oliver That's a good point. I had already noticed that the representation for Io was actually longer than the number it was encoding, so I wanted to move the values list around anyway. I'm not sure what a good way to go about finding a better order for compression would be tough, "get all permutations" isn't really runnable for 19 items.
– Kamil Drakari
yesterday
add a comment |
up vote
3
down vote
Japt, 77 76 75 bytes, score = 75
First pass at this; I wanted to try a 0 penalty solution to give myself a baseline to work off. Will come back to it tomorrow to see what improvements can be made, hopefully still for 0 penalty.
Input is case-insensitive.
n35 %87%52 g"..."ò)mc
Try it or test all inputs
The "..."
represents a string containing many unprintables. The codepoints are:
32,32,15,61,11,86,696,342,25,75,699,11,33,90,63,71,24,10,24,40,253,62,60,52,32,32,8,16,11,63,32,32,32,32,58,232,17,37,135,3,246,22,18,22,26,34,7,88
To offer a quick explanation: the string gets split into chunks of 2 characters. We then index into that array using part of ovs' formula plus some index-wrapping and then map the 2 characters to their codepoints.
- Saved a byte/point thanks to ETH
54 bytes, score = 58
A port of Olivier's solution.
"ýCĄ (ᬺ!˂Fɍ"cU¤¬xc %96%49)-7 *L
Test all inputs
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the%24
:-)
– ETHproductions
23 hours ago
@ETHproductions, that doesn't seem to work
– Shaggy
14 hours ago
Here's what I was thinking
– ETHproductions
12 hours ago
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
12 hours ago
add a comment |
up vote
2
down vote
PowerShell, 203 bytes, score 203
param($a)if($a-eq'Titan'){2575;exit}(696342,69911,58232,25362,24622,6371,6052,3390,2634,2440,2410,1822,1737,1561,1353,1186,1163,816,788)["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".indexOf(-join$a[0..1])/2]
Try it online!
Very similar to Olivier's answer, now that I see it, but developed independently.
add a comment |
up vote
2
down vote
Python 2, 155 bytes, score = 155
lambda p:int('G11KK54222111111XXNM8MCO37WQ53YXHE93V8BIF2IMH1WU9KPU2MLN HGR'['uSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])/2::20],35)
Try it online!
Surprisingly well for this lazy solution... will look into improving as well. ;-)
add a comment |
up vote
2
down vote
T-SQL, 203 bytes, score = 217
SELECT IIF(v='Titan',26,SUBSTRING(value,3,4))*100
FROM i,STRING_SPLIT('Ca24,Ea64,Er12,Eu16,Ga26,Ha8,Io18,Ju699,Ma34,Me24,Mo17,Ne246,Pl12,Sa582,Su6963,Ti8,Tr14,Ur254,Ve61',',')
WHERE LEFT(v,2)=LEFT(value,2)
Line breaks are for readability only.
Input is taken via pre-existing table i with varchar column v, per our IO standards.
Joins the input table to an in-memory table on the first two characters, and returns the remaining digits x100.
Treats "Titan" as a special case using IIF
.
add a comment |
up vote
2
down vote
Ruby, 105 bytes, score 109
->n{7E5/('!)"0 r&zZ&1#}3Mfh-~~d@'[0,j=" =1&%)AM<I>2,-B#($D 7@".index((n[1,9].sum%50+34).chr)].sum-j*32)}
Try it online!
If we divide 700000 by the radii, we get a sequence which increases reasonably linearly (though rather erratically). The increments in the table below can be approximated by the ASCII values of characters. The problem with this approach is it requires the input to be decoded to a value which orders the different names by size.
A minor issue is that the difference between Eris and Haumea is quite large. Three characters ~~d
are required to encode this increment in ASCII only format. The planet-to-index string has two "ghost planet"spaces in it to pad the index.
700000/r increment from previous
0.994774
9.960407 8.965633
11.95806 1.997657
27.45612 15.49805
28.28129 0.825178
109.2987 81.0174
115.0598 5.761118
205.4106 90.3508
264.3667 58.95612
270.4241 6.057335
285.3861 14.96199
288.9386 3.552524
382.1855 93.24692
400.8877 18.70223
446.0871 45.19939
514.6652 68.57806
587.1349 72.46972
598.7463 11.61144
853.3603 254.6139
883.6827 30.32245
add a comment |
up vote
1
down vote
Charcoal, 101 bytes, score = 101
I⍘§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²⁺§θ⁰§θχγ
Try it online! Link is to verbose version of code. Explanation:
⁺§θ⁰§θχ
Take the 1st and 11th character (cyclically) of the input string and concatenate them.
⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²
Look them up in the string SuJiSrUuNtEEVVMrGnTTMcClIIMoEpToPPEiHeTa
split into pairs of characters.
§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³
Split the string m.w'fv&J|"l|"e1 c& _c Ca ;e ;* 9a 9C 31 2; 0I .7 ,N ,7 (X (<
into groups of three characters and take the corresponding group.
I⍘ ... γ
Decode the result as a base-95 number using the printable ASCII character set as the digits. Example: Io
's 11th character is I
, so we look up II
and find it's the 13th largest object and its size is 31
which maps to 19 * 95 + 17 = 1822
.
add a comment |
15 Answers
15
active
oldest
votes
15 Answers
15
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
21
down vote
PowerShell, 3 bytes, score 3637
2e4
Try it online!
Very naive, boring, implementation; just returns 20000
no matter the input. Experimentation with things like special-casing the sun or using floating-point values instead of 2
all resulted in worse scores because the length of code increased enough to offset any size-comparison gains.
2
That's all you need to know about KPI :)
– mazzy
yesterday
6
Why is this getting so many votes?!
– Shaggy
yesterday
8
@Shaggy I'm confused about that as well.. :S It's by far the laziest and highest scoring answer (don't take it personal AdmBorkBork, but I think the Jelly and Java answers deserve the upvotes a lot more). People probably only see the 3 bytes part (or think higher score is better than lower) and ignore everything else. xD In Arnauld's original challenge description in the Sandbox, this answer wouldn't even have been possible, since it allowed a maximum error percentage of 95% for each I/O. Ah well. Enjoy the free rep AdmBorkBork. ;)
– Kevin Cruijssen
18 hours ago
2
@Elcan Or more precisely, it denotes that the rating system is not flawed, given that the resulting score is so high.
– Arnauld
15 hours ago
4
People upvote on PPCG for all sorts of reasons, not just because of raw score (see my huge Minecraft redstone answer for example). I upvoted this answer because it is a clear, simple example of the far end of the spectrum of strategy (the spectrum between "return exact values" vs "save bytes to return an approximation and take the penalty").
– BradC
11 hours ago
|
show 6 more comments
up vote
21
down vote
PowerShell, 3 bytes, score 3637
2e4
Try it online!
Very naive, boring, implementation; just returns 20000
no matter the input. Experimentation with things like special-casing the sun or using floating-point values instead of 2
all resulted in worse scores because the length of code increased enough to offset any size-comparison gains.
2
That's all you need to know about KPI :)
– mazzy
yesterday
6
Why is this getting so many votes?!
– Shaggy
yesterday
8
@Shaggy I'm confused about that as well.. :S It's by far the laziest and highest scoring answer (don't take it personal AdmBorkBork, but I think the Jelly and Java answers deserve the upvotes a lot more). People probably only see the 3 bytes part (or think higher score is better than lower) and ignore everything else. xD In Arnauld's original challenge description in the Sandbox, this answer wouldn't even have been possible, since it allowed a maximum error percentage of 95% for each I/O. Ah well. Enjoy the free rep AdmBorkBork. ;)
– Kevin Cruijssen
18 hours ago
2
@Elcan Or more precisely, it denotes that the rating system is not flawed, given that the resulting score is so high.
– Arnauld
15 hours ago
4
People upvote on PPCG for all sorts of reasons, not just because of raw score (see my huge Minecraft redstone answer for example). I upvoted this answer because it is a clear, simple example of the far end of the spectrum of strategy (the spectrum between "return exact values" vs "save bytes to return an approximation and take the penalty").
– BradC
11 hours ago
|
show 6 more comments
up vote
21
down vote
up vote
21
down vote
PowerShell, 3 bytes, score 3637
2e4
Try it online!
Very naive, boring, implementation; just returns 20000
no matter the input. Experimentation with things like special-casing the sun or using floating-point values instead of 2
all resulted in worse scores because the length of code increased enough to offset any size-comparison gains.
PowerShell, 3 bytes, score 3637
2e4
Try it online!
Very naive, boring, implementation; just returns 20000
no matter the input. Experimentation with things like special-casing the sun or using floating-point values instead of 2
all resulted in worse scores because the length of code increased enough to offset any size-comparison gains.
answered yesterday
AdmBorkBork
25.9k363226
25.9k363226
2
That's all you need to know about KPI :)
– mazzy
yesterday
6
Why is this getting so many votes?!
– Shaggy
yesterday
8
@Shaggy I'm confused about that as well.. :S It's by far the laziest and highest scoring answer (don't take it personal AdmBorkBork, but I think the Jelly and Java answers deserve the upvotes a lot more). People probably only see the 3 bytes part (or think higher score is better than lower) and ignore everything else. xD In Arnauld's original challenge description in the Sandbox, this answer wouldn't even have been possible, since it allowed a maximum error percentage of 95% for each I/O. Ah well. Enjoy the free rep AdmBorkBork. ;)
– Kevin Cruijssen
18 hours ago
2
@Elcan Or more precisely, it denotes that the rating system is not flawed, given that the resulting score is so high.
– Arnauld
15 hours ago
4
People upvote on PPCG for all sorts of reasons, not just because of raw score (see my huge Minecraft redstone answer for example). I upvoted this answer because it is a clear, simple example of the far end of the spectrum of strategy (the spectrum between "return exact values" vs "save bytes to return an approximation and take the penalty").
– BradC
11 hours ago
|
show 6 more comments
2
That's all you need to know about KPI :)
– mazzy
yesterday
6
Why is this getting so many votes?!
– Shaggy
yesterday
8
@Shaggy I'm confused about that as well.. :S It's by far the laziest and highest scoring answer (don't take it personal AdmBorkBork, but I think the Jelly and Java answers deserve the upvotes a lot more). People probably only see the 3 bytes part (or think higher score is better than lower) and ignore everything else. xD In Arnauld's original challenge description in the Sandbox, this answer wouldn't even have been possible, since it allowed a maximum error percentage of 95% for each I/O. Ah well. Enjoy the free rep AdmBorkBork. ;)
– Kevin Cruijssen
18 hours ago
2
@Elcan Or more precisely, it denotes that the rating system is not flawed, given that the resulting score is so high.
– Arnauld
15 hours ago
4
People upvote on PPCG for all sorts of reasons, not just because of raw score (see my huge Minecraft redstone answer for example). I upvoted this answer because it is a clear, simple example of the far end of the spectrum of strategy (the spectrum between "return exact values" vs "save bytes to return an approximation and take the penalty").
– BradC
11 hours ago
2
2
That's all you need to know about KPI :)
– mazzy
yesterday
That's all you need to know about KPI :)
– mazzy
yesterday
6
6
Why is this getting so many votes?!
– Shaggy
yesterday
Why is this getting so many votes?!
– Shaggy
yesterday
8
8
@Shaggy I'm confused about that as well.. :S It's by far the laziest and highest scoring answer (don't take it personal AdmBorkBork, but I think the Jelly and Java answers deserve the upvotes a lot more). People probably only see the 3 bytes part (or think higher score is better than lower) and ignore everything else. xD In Arnauld's original challenge description in the Sandbox, this answer wouldn't even have been possible, since it allowed a maximum error percentage of 95% for each I/O. Ah well. Enjoy the free rep AdmBorkBork. ;)
– Kevin Cruijssen
18 hours ago
@Shaggy I'm confused about that as well.. :S It's by far the laziest and highest scoring answer (don't take it personal AdmBorkBork, but I think the Jelly and Java answers deserve the upvotes a lot more). People probably only see the 3 bytes part (or think higher score is better than lower) and ignore everything else. xD In Arnauld's original challenge description in the Sandbox, this answer wouldn't even have been possible, since it allowed a maximum error percentage of 95% for each I/O. Ah well. Enjoy the free rep AdmBorkBork. ;)
– Kevin Cruijssen
18 hours ago
2
2
@Elcan Or more precisely, it denotes that the rating system is not flawed, given that the resulting score is so high.
– Arnauld
15 hours ago
@Elcan Or more precisely, it denotes that the rating system is not flawed, given that the resulting score is so high.
– Arnauld
15 hours ago
4
4
People upvote on PPCG for all sorts of reasons, not just because of raw score (see my huge Minecraft redstone answer for example). I upvoted this answer because it is a clear, simple example of the far end of the spectrum of strategy (the spectrum between "return exact values" vs "save bytes to return an approximation and take the penalty").
– BradC
11 hours ago
People upvote on PPCG for all sorts of reasons, not just because of raw score (see my huge Minecraft redstone answer for example). I upvoted this answer because it is a clear, simple example of the far end of the spectrum of strategy (the spectrum between "return exact values" vs "save bytes to return an approximation and take the penalty").
– BradC
11 hours ago
|
show 6 more comments
up vote
15
down vote
Jelly, 34 bytes, score = 37
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1*
Input is in uppercase, output is the power of 1.1 with the least error.
Try it online!
How it works
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1* Main link. Argument: s (string)
O Ordinal; map the char in s to their code points.
"ERIS" -> [69,82,73,83]
Ḍ Undecimal; treat the result as an array of digits
in base 10 and convert it to integer.
[69,82,73,83] -> 69000+8200+730+83 = 78013
“⁸|5/!‘ Literal; yield [136, 124, 53, 47, 33].
%ƒ Fold the array by modulus, using the computed
integer as initial value.
78013 -> 78013%136%124%53%47%33 = 32
“RNFLOJMjs⁽u[USJ‘ Literal; yield [82, 78, 70, 76, 79, 74, 77, ...
106, 115, 141, 92, 117, 91, 85, 83, 74].
ị Retrieve the element from the array to the right,
at the index to the left.
Indexing is 1-based and modular.
32 = 16 (mod 16) -> 'J' = 74
1.1* Raise 1.1 to the computed power.
74 = 1.1**74 = 1156.268519450066
Would a "salt with given string, hash, and convert to integer" builtin be useful in Jelly? Or perhaps one that also is modular in case you're not just indexing into an array?
– lirtosiast
23 hours ago
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
14 hours ago
er, "then take the result mod n".
– lirtosiast
3 hours ago
add a comment |
up vote
15
down vote
Jelly, 34 bytes, score = 37
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1*
Input is in uppercase, output is the power of 1.1 with the least error.
Try it online!
How it works
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1* Main link. Argument: s (string)
O Ordinal; map the char in s to their code points.
"ERIS" -> [69,82,73,83]
Ḍ Undecimal; treat the result as an array of digits
in base 10 and convert it to integer.
[69,82,73,83] -> 69000+8200+730+83 = 78013
“⁸|5/!‘ Literal; yield [136, 124, 53, 47, 33].
%ƒ Fold the array by modulus, using the computed
integer as initial value.
78013 -> 78013%136%124%53%47%33 = 32
“RNFLOJMjs⁽u[USJ‘ Literal; yield [82, 78, 70, 76, 79, 74, 77, ...
106, 115, 141, 92, 117, 91, 85, 83, 74].
ị Retrieve the element from the array to the right,
at the index to the left.
Indexing is 1-based and modular.
32 = 16 (mod 16) -> 'J' = 74
1.1* Raise 1.1 to the computed power.
74 = 1.1**74 = 1156.268519450066
Would a "salt with given string, hash, and convert to integer" builtin be useful in Jelly? Or perhaps one that also is modular in case you're not just indexing into an array?
– lirtosiast
23 hours ago
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
14 hours ago
er, "then take the result mod n".
– lirtosiast
3 hours ago
add a comment |
up vote
15
down vote
up vote
15
down vote
Jelly, 34 bytes, score = 37
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1*
Input is in uppercase, output is the power of 1.1 with the least error.
Try it online!
How it works
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1* Main link. Argument: s (string)
O Ordinal; map the char in s to their code points.
"ERIS" -> [69,82,73,83]
Ḍ Undecimal; treat the result as an array of digits
in base 10 and convert it to integer.
[69,82,73,83] -> 69000+8200+730+83 = 78013
“⁸|5/!‘ Literal; yield [136, 124, 53, 47, 33].
%ƒ Fold the array by modulus, using the computed
integer as initial value.
78013 -> 78013%136%124%53%47%33 = 32
“RNFLOJMjs⁽u[USJ‘ Literal; yield [82, 78, 70, 76, 79, 74, 77, ...
106, 115, 141, 92, 117, 91, 85, 83, 74].
ị Retrieve the element from the array to the right,
at the index to the left.
Indexing is 1-based and modular.
32 = 16 (mod 16) -> 'J' = 74
1.1* Raise 1.1 to the computed power.
74 = 1.1**74 = 1156.268519450066
Jelly, 34 bytes, score = 37
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1*
Input is in uppercase, output is the power of 1.1 with the least error.
Try it online!
How it works
OḌ“⁸|5/!‘%ƒị“RNFLOJMjs⁽u[USJ‘1.1* Main link. Argument: s (string)
O Ordinal; map the char in s to their code points.
"ERIS" -> [69,82,73,83]
Ḍ Undecimal; treat the result as an array of digits
in base 10 and convert it to integer.
[69,82,73,83] -> 69000+8200+730+83 = 78013
“⁸|5/!‘ Literal; yield [136, 124, 53, 47, 33].
%ƒ Fold the array by modulus, using the computed
integer as initial value.
78013 -> 78013%136%124%53%47%33 = 32
“RNFLOJMjs⁽u[USJ‘ Literal; yield [82, 78, 70, 76, 79, 74, 77, ...
106, 115, 141, 92, 117, 91, 85, 83, 74].
ị Retrieve the element from the array to the right,
at the index to the left.
Indexing is 1-based and modular.
32 = 16 (mod 16) -> 'J' = 74
1.1* Raise 1.1 to the computed power.
74 = 1.1**74 = 1156.268519450066
edited 14 hours ago
answered yesterday
Dennis♦
185k32295733
185k32295733
Would a "salt with given string, hash, and convert to integer" builtin be useful in Jelly? Or perhaps one that also is modular in case you're not just indexing into an array?
– lirtosiast
23 hours ago
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
14 hours ago
er, "then take the result mod n".
– lirtosiast
3 hours ago
add a comment |
Would a "salt with given string, hash, and convert to integer" builtin be useful in Jelly? Or perhaps one that also is modular in case you're not just indexing into an array?
– lirtosiast
23 hours ago
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
14 hours ago
er, "then take the result mod n".
– lirtosiast
3 hours ago
Would a "salt with given string, hash, and convert to integer" builtin be useful in Jelly? Or perhaps one that also is modular in case you're not just indexing into an array?
– lirtosiast
23 hours ago
Would a "salt with given string, hash, and convert to integer" builtin be useful in Jelly? Or perhaps one that also is modular in case you're not just indexing into an array?
– lirtosiast
23 hours ago
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
14 hours ago
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
14 hours ago
er, "then take the result mod n".
– lirtosiast
3 hours ago
er, "then take the result mod n".
– lirtosiast
3 hours ago
add a comment |
up vote
13
down vote
Java (JDK), 90 bytes, score = 97
s->("ýCĄ (ᬺ!˂Fɍ".charAt(s.substring(2).chars().sum()%96%49%25)-7)*100
Try it online!
- This entry uses both undisplayable and multi-byte Unicode characters (but Java accepts them nevertheless). Check the TIO for the accurate code.
- The input must be title-case.
- This code rounds the values to the best multiple-of-100 (sometimes up, sometimes down) so that the last two digits can be skipped when encoded, and the value can then be approximated by multiplying by 100.
- This entry uses various hashes to fit a 25 codepoints string (shortest string I could find).
Credits
- -48 score (-45 bytes) thanks to Kevin Cruijssen by encoding the radiuses (divided by 100) directly in a
String
instead of hardcoding them in an explicitint
array..
2
96 bytes & 103 score with the same output.
– Kevin Cruijssen
yesterday
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
yesterday
Glad I could help, and nice answer! :) PS: As for why I added the(...-7)
: The unprintable character(char)0
is empty so I had to add something. I first tried9
and8
being single digits, but9
gave of course tabs, requiring multiplet
(2 bytes each), and8
gave an error about an unescaped character used.
– Kevin Cruijssen
yesterday
@KevinCruijssen To be honest, I tried for a few hours yesterday to get better values by expanding your multiplication into*100-700
and playing with the values-as-string and those two numbers, but those are the best, actually, Some values can decrease the byte count, but then the score stays the same. So random pinpointing made (one of) the best case ;)
– Olivier Grégoire
17 hours ago
Talk about undisplayable! This entry really weirds out my Firefox to the point that I can't actually read the rest of the page properly :-(
– Neil
17 hours ago
|
show 2 more comments
up vote
13
down vote
Java (JDK), 90 bytes, score = 97
s->("ýCĄ (ᬺ!˂Fɍ".charAt(s.substring(2).chars().sum()%96%49%25)-7)*100
Try it online!
- This entry uses both undisplayable and multi-byte Unicode characters (but Java accepts them nevertheless). Check the TIO for the accurate code.
- The input must be title-case.
- This code rounds the values to the best multiple-of-100 (sometimes up, sometimes down) so that the last two digits can be skipped when encoded, and the value can then be approximated by multiplying by 100.
- This entry uses various hashes to fit a 25 codepoints string (shortest string I could find).
Credits
- -48 score (-45 bytes) thanks to Kevin Cruijssen by encoding the radiuses (divided by 100) directly in a
String
instead of hardcoding them in an explicitint
array..
2
96 bytes & 103 score with the same output.
– Kevin Cruijssen
yesterday
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
yesterday
Glad I could help, and nice answer! :) PS: As for why I added the(...-7)
: The unprintable character(char)0
is empty so I had to add something. I first tried9
and8
being single digits, but9
gave of course tabs, requiring multiplet
(2 bytes each), and8
gave an error about an unescaped character used.
– Kevin Cruijssen
yesterday
@KevinCruijssen To be honest, I tried for a few hours yesterday to get better values by expanding your multiplication into*100-700
and playing with the values-as-string and those two numbers, but those are the best, actually, Some values can decrease the byte count, but then the score stays the same. So random pinpointing made (one of) the best case ;)
– Olivier Grégoire
17 hours ago
Talk about undisplayable! This entry really weirds out my Firefox to the point that I can't actually read the rest of the page properly :-(
– Neil
17 hours ago
|
show 2 more comments
up vote
13
down vote
up vote
13
down vote
Java (JDK), 90 bytes, score = 97
s->("ýCĄ (ᬺ!˂Fɍ".charAt(s.substring(2).chars().sum()%96%49%25)-7)*100
Try it online!
- This entry uses both undisplayable and multi-byte Unicode characters (but Java accepts them nevertheless). Check the TIO for the accurate code.
- The input must be title-case.
- This code rounds the values to the best multiple-of-100 (sometimes up, sometimes down) so that the last two digits can be skipped when encoded, and the value can then be approximated by multiplying by 100.
- This entry uses various hashes to fit a 25 codepoints string (shortest string I could find).
Credits
- -48 score (-45 bytes) thanks to Kevin Cruijssen by encoding the radiuses (divided by 100) directly in a
String
instead of hardcoding them in an explicitint
array..
Java (JDK), 90 bytes, score = 97
s->("ýCĄ (ᬺ!˂Fɍ".charAt(s.substring(2).chars().sum()%96%49%25)-7)*100
Try it online!
- This entry uses both undisplayable and multi-byte Unicode characters (but Java accepts them nevertheless). Check the TIO for the accurate code.
- The input must be title-case.
- This code rounds the values to the best multiple-of-100 (sometimes up, sometimes down) so that the last two digits can be skipped when encoded, and the value can then be approximated by multiplying by 100.
- This entry uses various hashes to fit a 25 codepoints string (shortest string I could find).
Credits
- -48 score (-45 bytes) thanks to Kevin Cruijssen by encoding the radiuses (divided by 100) directly in a
String
instead of hardcoding them in an explicitint
array..
edited 16 hours ago
answered yesterday
Olivier Grégoire
8,47711843
8,47711843
2
96 bytes & 103 score with the same output.
– Kevin Cruijssen
yesterday
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
yesterday
Glad I could help, and nice answer! :) PS: As for why I added the(...-7)
: The unprintable character(char)0
is empty so I had to add something. I first tried9
and8
being single digits, but9
gave of course tabs, requiring multiplet
(2 bytes each), and8
gave an error about an unescaped character used.
– Kevin Cruijssen
yesterday
@KevinCruijssen To be honest, I tried for a few hours yesterday to get better values by expanding your multiplication into*100-700
and playing with the values-as-string and those two numbers, but those are the best, actually, Some values can decrease the byte count, but then the score stays the same. So random pinpointing made (one of) the best case ;)
– Olivier Grégoire
17 hours ago
Talk about undisplayable! This entry really weirds out my Firefox to the point that I can't actually read the rest of the page properly :-(
– Neil
17 hours ago
|
show 2 more comments
2
96 bytes & 103 score with the same output.
– Kevin Cruijssen
yesterday
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
yesterday
Glad I could help, and nice answer! :) PS: As for why I added the(...-7)
: The unprintable character(char)0
is empty so I had to add something. I first tried9
and8
being single digits, but9
gave of course tabs, requiring multiplet
(2 bytes each), and8
gave an error about an unescaped character used.
– Kevin Cruijssen
yesterday
@KevinCruijssen To be honest, I tried for a few hours yesterday to get better values by expanding your multiplication into*100-700
and playing with the values-as-string and those two numbers, but those are the best, actually, Some values can decrease the byte count, but then the score stays the same. So random pinpointing made (one of) the best case ;)
– Olivier Grégoire
17 hours ago
Talk about undisplayable! This entry really weirds out my Firefox to the point that I can't actually read the rest of the page properly :-(
– Neil
17 hours ago
2
2
96 bytes & 103 score with the same output.
– Kevin Cruijssen
yesterday
96 bytes & 103 score with the same output.
– Kevin Cruijssen
yesterday
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
yesterday
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
yesterday
Glad I could help, and nice answer! :) PS: As for why I added the
(...-7)
: The unprintable character (char)0
is empty so I had to add something. I first tried 9
and 8
being single digits, but 9
gave of course tabs, requiring multiple t
(2 bytes each), and 8
gave an error about an unescaped character used.– Kevin Cruijssen
yesterday
Glad I could help, and nice answer! :) PS: As for why I added the
(...-7)
: The unprintable character (char)0
is empty so I had to add something. I first tried 9
and 8
being single digits, but 9
gave of course tabs, requiring multiple t
(2 bytes each), and 8
gave an error about an unescaped character used.– Kevin Cruijssen
yesterday
@KevinCruijssen To be honest, I tried for a few hours yesterday to get better values by expanding your multiplication into
*100-700
and playing with the values-as-string and those two numbers, but those are the best, actually, Some values can decrease the byte count, but then the score stays the same. So random pinpointing made (one of) the best case ;)– Olivier Grégoire
17 hours ago
@KevinCruijssen To be honest, I tried for a few hours yesterday to get better values by expanding your multiplication into
*100-700
and playing with the values-as-string and those two numbers, but those are the best, actually, Some values can decrease the byte count, but then the score stays the same. So random pinpointing made (one of) the best case ;)– Olivier Grégoire
17 hours ago
Talk about undisplayable! This entry really weirds out my Firefox to the point that I can't actually read the rest of the page properly :-(
– Neil
17 hours ago
Talk about undisplayable! This entry really weirds out my Firefox to the point that I can't actually read the rest of the page properly :-(
– Neil
17 hours ago
|
show 2 more comments
up vote
8
down vote
Wolfram Language 114 103 97 88 86 83 bytes. score = 114 103 97 89 87 84 points
#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/."NotAvailable"->816&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 2 more thanks to user202729
.
Although Mathematica can fetch solar system data (as well as much additional astronomical data), some minor tweaks are needed, as explained below.
Interpreter[#,"AstronomicalObject"]&
will return the entity (i.e. the machine computable object) associated with the term represented by #
.
EntityValue[AstronomicalObject,"Radius"]
returns the radius, in miles, of the entity.
"Haumea" returns the value, "NotAvailable", which is replaced by 816.
Multiplication of the radius by 1.61
converts from miles to km. Decimal values, rather than integers, account for much less than 1% error, even in the most extreme case.
[[1]]
returns the magnitude without the unit, km. This was later changed to #&@@
, yielding the same result.
Another wolfram built in. Just like detecting downgoats
– OganM
3 hours ago
I would've answered this but I don't know the wolfram language lol
– Quintec
2 hours ago
add a comment |
up vote
8
down vote
Wolfram Language 114 103 97 88 86 83 bytes. score = 114 103 97 89 87 84 points
#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/."NotAvailable"->816&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 2 more thanks to user202729
.
Although Mathematica can fetch solar system data (as well as much additional astronomical data), some minor tweaks are needed, as explained below.
Interpreter[#,"AstronomicalObject"]&
will return the entity (i.e. the machine computable object) associated with the term represented by #
.
EntityValue[AstronomicalObject,"Radius"]
returns the radius, in miles, of the entity.
"Haumea" returns the value, "NotAvailable", which is replaced by 816.
Multiplication of the radius by 1.61
converts from miles to km. Decimal values, rather than integers, account for much less than 1% error, even in the most extreme case.
[[1]]
returns the magnitude without the unit, km. This was later changed to #&@@
, yielding the same result.
Another wolfram built in. Just like detecting downgoats
– OganM
3 hours ago
I would've answered this but I don't know the wolfram language lol
– Quintec
2 hours ago
add a comment |
up vote
8
down vote
up vote
8
down vote
Wolfram Language 114 103 97 88 86 83 bytes. score = 114 103 97 89 87 84 points
#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/."NotAvailable"->816&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 2 more thanks to user202729
.
Although Mathematica can fetch solar system data (as well as much additional astronomical data), some minor tweaks are needed, as explained below.
Interpreter[#,"AstronomicalObject"]&
will return the entity (i.e. the machine computable object) associated with the term represented by #
.
EntityValue[AstronomicalObject,"Radius"]
returns the radius, in miles, of the entity.
"Haumea" returns the value, "NotAvailable", which is replaced by 816.
Multiplication of the radius by 1.61
converts from miles to km. Decimal values, rather than integers, account for much less than 1% error, even in the most extreme case.
[[1]]
returns the magnitude without the unit, km. This was later changed to #&@@
, yielding the same result.
Wolfram Language 114 103 97 88 86 83 bytes. score = 114 103 97 89 87 84 points
#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/."NotAvailable"->816&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 2 more thanks to user202729
.
Although Mathematica can fetch solar system data (as well as much additional astronomical data), some minor tweaks are needed, as explained below.
Interpreter[#,"AstronomicalObject"]&
will return the entity (i.e. the machine computable object) associated with the term represented by #
.
EntityValue[AstronomicalObject,"Radius"]
returns the radius, in miles, of the entity.
"Haumea" returns the value, "NotAvailable", which is replaced by 816.
Multiplication of the radius by 1.61
converts from miles to km. Decimal values, rather than integers, account for much less than 1% error, even in the most extreme case.
[[1]]
returns the magnitude without the unit, km. This was later changed to #&@@
, yielding the same result.
edited 32 mins ago
answered yesterday
DavidC
23.7k243102
23.7k243102
Another wolfram built in. Just like detecting downgoats
– OganM
3 hours ago
I would've answered this but I don't know the wolfram language lol
– Quintec
2 hours ago
add a comment |
Another wolfram built in. Just like detecting downgoats
– OganM
3 hours ago
I would've answered this but I don't know the wolfram language lol
– Quintec
2 hours ago
Another wolfram built in. Just like detecting downgoats
– OganM
3 hours ago
Another wolfram built in. Just like detecting downgoats
– OganM
3 hours ago
I would've answered this but I don't know the wolfram language lol
– Quintec
2 hours ago
I would've answered this but I don't know the wolfram language lol
– Quintec
2 hours ago
add a comment |
up vote
7
down vote
Python 3, score 95, 95 bytes
lambda n:ord("ؙҢਏ𑄗ാᣣ४ঈ挒ឤ?̰ҋ??ۉՉ怮ܞ̔"[int(n,35)%87%52%24-1])
Try it online!
Python 3, score 133, 133 bytes
lambda n:int(f'00e0{10**18+10**6}10x1h2411j4?00??811i1207wazxmwuvko?mw??xc1ze1ldyujz6zysi4?ob??k9lym6w'[int(n,35)%87%52%24-1::23],36)
Try it online!
add a comment |
up vote
7
down vote
Python 3, score 95, 95 bytes
lambda n:ord("ؙҢਏ𑄗ാᣣ४ঈ挒ឤ?̰ҋ??ۉՉ怮ܞ̔"[int(n,35)%87%52%24-1])
Try it online!
Python 3, score 133, 133 bytes
lambda n:int(f'00e0{10**18+10**6}10x1h2411j4?00??811i1207wazxmwuvko?mw??xc1ze1ldyujz6zysi4?ob??k9lym6w'[int(n,35)%87%52%24-1::23],36)
Try it online!
add a comment |
up vote
7
down vote
up vote
7
down vote
Python 3, score 95, 95 bytes
lambda n:ord("ؙҢਏ𑄗ാᣣ४ঈ挒ឤ?̰ҋ??ۉՉ怮ܞ̔"[int(n,35)%87%52%24-1])
Try it online!
Python 3, score 133, 133 bytes
lambda n:int(f'00e0{10**18+10**6}10x1h2411j4?00??811i1207wazxmwuvko?mw??xc1ze1ldyujz6zysi4?ob??k9lym6w'[int(n,35)%87%52%24-1::23],36)
Try it online!
Python 3, score 95, 95 bytes
lambda n:ord("ؙҢਏ𑄗ാᣣ४ঈ挒ឤ?̰ҋ??ۉՉ怮ܞ̔"[int(n,35)%87%52%24-1])
Try it online!
Python 3, score 133, 133 bytes
lambda n:int(f'00e0{10**18+10**6}10x1h2411j4?00??811i1207wazxmwuvko?mw??xc1ze1ldyujz6zysi4?ob??k9lym6w'[int(n,35)%87%52%24-1::23],36)
Try it online!
edited yesterday
answered yesterday
ovs
18.4k21059
18.4k21059
add a comment |
add a comment |
up vote
4
down vote
05AB1E, score 100 66 60 (100 61 56 bytes)
•1∞²îc|I‰∍T‡sÇ3¡ò½в…»Ë•§•1ë£ñƒq£û¿’…•S£y¦¦ÇO96%49%25%èт*
Port of @OlivierGrégoire's Java answer, so if you like this first answer, make sure to upvote him as well!
Input in titlecase.
Verify all test cases.
05AB1E, score 100 (100 bytes)
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•§•3«8¹ØмS7Ç•S£.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•3ôI2£Iθ«kè
Input in full lowercase. Outputs the exact radius, so no penalty is added.
Verify all test cases.
Explanation:
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•
# Compressed integer 696342699115823225362246226371605233902634257524402410182217371561135311861163816788
§ # Casted to string (bug, should have been implicitly..)
•3«8¹ØмS7Ç• # Compressed integer 65555444444444444433
S # Converted to a list of digits: [6,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3]
£ # The first integer is split into parts of that size: ["696342","69911","58232","25362","24622","6371","6052","3390","2634","2575","2440","2410","1822","1737","1561","1353","1186","1163","816","788"]
.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•
# Compressed string "sunjursanursneeeahvesmasgaetinmeycaoioomoneuatrnploershaatia"
3ô # Split into parts of size 3: ["sun","jur","san","urs","nee","eah","ves","mas","gae","tin","mey","cao","ioo","mon","eua","trn","plo","ers","haa","tia"]
I2£ # The first two characters of the input
Iθ # The last character of the input
« # Merged together
k # Get the index of this string in the list of strings
è # And use that index to index into the list of integers
# (and output the result implicitly)
See this 05AB1E tip of mine (sections How to compress large integers? and How to compress strings not part of the dictionary?) to understand how the compression used works.
I did create a 70-bytes alternative which would map sun to 600,000
; [jupiter,saturn] to 60,000
; [uranus,neptune] to 30,000
; [earth,venus] to 6,000
; [mars,ganymede,titan,mercury,callisto] to 3,000
; [io,moon,europa,triton,pluto,eris] to 1,500
; and [haumea;titania] to 750
. Unfortunately that got a score of 117. I will see if I can get below 100 with an alternative approach later.
1
I found a better hash that use a 25-chars string instead of a 30-chars one. Check my Java answer if you want to update this answer ;)
– Olivier Grégoire
16 hours ago
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
16 hours ago
add a comment |
up vote
4
down vote
05AB1E, score 100 66 60 (100 61 56 bytes)
•1∞²îc|I‰∍T‡sÇ3¡ò½в…»Ë•§•1ë£ñƒq£û¿’…•S£y¦¦ÇO96%49%25%èт*
Port of @OlivierGrégoire's Java answer, so if you like this first answer, make sure to upvote him as well!
Input in titlecase.
Verify all test cases.
05AB1E, score 100 (100 bytes)
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•§•3«8¹ØмS7Ç•S£.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•3ôI2£Iθ«kè
Input in full lowercase. Outputs the exact radius, so no penalty is added.
Verify all test cases.
Explanation:
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•
# Compressed integer 696342699115823225362246226371605233902634257524402410182217371561135311861163816788
§ # Casted to string (bug, should have been implicitly..)
•3«8¹ØмS7Ç• # Compressed integer 65555444444444444433
S # Converted to a list of digits: [6,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3]
£ # The first integer is split into parts of that size: ["696342","69911","58232","25362","24622","6371","6052","3390","2634","2575","2440","2410","1822","1737","1561","1353","1186","1163","816","788"]
.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•
# Compressed string "sunjursanursneeeahvesmasgaetinmeycaoioomoneuatrnploershaatia"
3ô # Split into parts of size 3: ["sun","jur","san","urs","nee","eah","ves","mas","gae","tin","mey","cao","ioo","mon","eua","trn","plo","ers","haa","tia"]
I2£ # The first two characters of the input
Iθ # The last character of the input
« # Merged together
k # Get the index of this string in the list of strings
è # And use that index to index into the list of integers
# (and output the result implicitly)
See this 05AB1E tip of mine (sections How to compress large integers? and How to compress strings not part of the dictionary?) to understand how the compression used works.
I did create a 70-bytes alternative which would map sun to 600,000
; [jupiter,saturn] to 60,000
; [uranus,neptune] to 30,000
; [earth,venus] to 6,000
; [mars,ganymede,titan,mercury,callisto] to 3,000
; [io,moon,europa,triton,pluto,eris] to 1,500
; and [haumea;titania] to 750
. Unfortunately that got a score of 117. I will see if I can get below 100 with an alternative approach later.
1
I found a better hash that use a 25-chars string instead of a 30-chars one. Check my Java answer if you want to update this answer ;)
– Olivier Grégoire
16 hours ago
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
16 hours ago
add a comment |
up vote
4
down vote
up vote
4
down vote
05AB1E, score 100 66 60 (100 61 56 bytes)
•1∞²îc|I‰∍T‡sÇ3¡ò½в…»Ë•§•1ë£ñƒq£û¿’…•S£y¦¦ÇO96%49%25%èт*
Port of @OlivierGrégoire's Java answer, so if you like this first answer, make sure to upvote him as well!
Input in titlecase.
Verify all test cases.
05AB1E, score 100 (100 bytes)
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•§•3«8¹ØмS7Ç•S£.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•3ôI2£Iθ«kè
Input in full lowercase. Outputs the exact radius, so no penalty is added.
Verify all test cases.
Explanation:
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•
# Compressed integer 696342699115823225362246226371605233902634257524402410182217371561135311861163816788
§ # Casted to string (bug, should have been implicitly..)
•3«8¹ØмS7Ç• # Compressed integer 65555444444444444433
S # Converted to a list of digits: [6,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3]
£ # The first integer is split into parts of that size: ["696342","69911","58232","25362","24622","6371","6052","3390","2634","2575","2440","2410","1822","1737","1561","1353","1186","1163","816","788"]
.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•
# Compressed string "sunjursanursneeeahvesmasgaetinmeycaoioomoneuatrnploershaatia"
3ô # Split into parts of size 3: ["sun","jur","san","urs","nee","eah","ves","mas","gae","tin","mey","cao","ioo","mon","eua","trn","plo","ers","haa","tia"]
I2£ # The first two characters of the input
Iθ # The last character of the input
« # Merged together
k # Get the index of this string in the list of strings
è # And use that index to index into the list of integers
# (and output the result implicitly)
See this 05AB1E tip of mine (sections How to compress large integers? and How to compress strings not part of the dictionary?) to understand how the compression used works.
I did create a 70-bytes alternative which would map sun to 600,000
; [jupiter,saturn] to 60,000
; [uranus,neptune] to 30,000
; [earth,venus] to 6,000
; [mars,ganymede,titan,mercury,callisto] to 3,000
; [io,moon,europa,triton,pluto,eris] to 1,500
; and [haumea;titania] to 750
. Unfortunately that got a score of 117. I will see if I can get below 100 with an alternative approach later.
05AB1E, score 100 66 60 (100 61 56 bytes)
•1∞²îc|I‰∍T‡sÇ3¡ò½в…»Ë•§•1ë£ñƒq£û¿’…•S£y¦¦ÇO96%49%25%èт*
Port of @OlivierGrégoire's Java answer, so if you like this first answer, make sure to upvote him as well!
Input in titlecase.
Verify all test cases.
05AB1E, score 100 (100 bytes)
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•§•3«8¹ØмS7Ç•S£.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•3ôI2£Iθ«kè
Input in full lowercase. Outputs the exact radius, so no penalty is added.
Verify all test cases.
Explanation:
•*Òâ%ÌÜS…Ùb‹Úi{e!]ɸ·vÌBUSηHã£āðxyµŠ•
# Compressed integer 696342699115823225362246226371605233902634257524402410182217371561135311861163816788
§ # Casted to string (bug, should have been implicitly..)
•3«8¹ØмS7Ç• # Compressed integer 65555444444444444433
S # Converted to a list of digits: [6,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3]
£ # The first integer is split into parts of that size: ["696342","69911","58232","25362","24622","6371","6052","3390","2634","2575","2440","2410","1822","1737","1561","1353","1186","1163","816","788"]
.•WùηƵ@,Sº,ûεβʒóÃX¹Θäáá’Ý)”Ωož∞-z.A±D•
# Compressed string "sunjursanursneeeahvesmasgaetinmeycaoioomoneuatrnploershaatia"
3ô # Split into parts of size 3: ["sun","jur","san","urs","nee","eah","ves","mas","gae","tin","mey","cao","ioo","mon","eua","trn","plo","ers","haa","tia"]
I2£ # The first two characters of the input
Iθ # The last character of the input
« # Merged together
k # Get the index of this string in the list of strings
è # And use that index to index into the list of integers
# (and output the result implicitly)
See this 05AB1E tip of mine (sections How to compress large integers? and How to compress strings not part of the dictionary?) to understand how the compression used works.
I did create a 70-bytes alternative which would map sun to 600,000
; [jupiter,saturn] to 60,000
; [uranus,neptune] to 30,000
; [earth,venus] to 6,000
; [mars,ganymede,titan,mercury,callisto] to 3,000
; [io,moon,europa,triton,pluto,eris] to 1,500
; and [haumea;titania] to 750
. Unfortunately that got a score of 117. I will see if I can get below 100 with an alternative approach later.
edited 16 hours ago
answered yesterday
Kevin Cruijssen
34.9k554184
34.9k554184
1
I found a better hash that use a 25-chars string instead of a 30-chars one. Check my Java answer if you want to update this answer ;)
– Olivier Grégoire
16 hours ago
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
16 hours ago
add a comment |
1
I found a better hash that use a 25-chars string instead of a 30-chars one. Check my Java answer if you want to update this answer ;)
– Olivier Grégoire
16 hours ago
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
16 hours ago
1
1
I found a better hash that use a 25-chars string instead of a 30-chars one. Check my Java answer if you want to update this answer ;)
– Olivier Grégoire
16 hours ago
I found a better hash that use a 25-chars string instead of a 30-chars one. Check my Java answer if you want to update this answer ;)
– Olivier Grégoire
16 hours ago
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
16 hours ago
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
16 hours ago
add a comment |
up vote
4
down vote
Mathematica, 57 bytes, score = 62 58
-4 bytes/score thanks to lirtosiast!
#&@@WolframAlpha[#<>" size km","Result"]]/._Missing->816&
Just does a Wolfram Alpha lookup for the mean radius.
@lirtosiast Thanks!
– LegionMammal978
15 hours ago
add a comment |
up vote
4
down vote
Mathematica, 57 bytes, score = 62 58
-4 bytes/score thanks to lirtosiast!
#&@@WolframAlpha[#<>" size km","Result"]]/._Missing->816&
Just does a Wolfram Alpha lookup for the mean radius.
@lirtosiast Thanks!
– LegionMammal978
15 hours ago
add a comment |
up vote
4
down vote
up vote
4
down vote
Mathematica, 57 bytes, score = 62 58
-4 bytes/score thanks to lirtosiast!
#&@@WolframAlpha[#<>" size km","Result"]]/._Missing->816&
Just does a Wolfram Alpha lookup for the mean radius.
Mathematica, 57 bytes, score = 62 58
-4 bytes/score thanks to lirtosiast!
#&@@WolframAlpha[#<>" size km","Result"]]/._Missing->816&
Just does a Wolfram Alpha lookup for the mean radius.
edited 15 hours ago
answered yesterday
LegionMammal978
15k41852
15k41852
@lirtosiast Thanks!
– LegionMammal978
15 hours ago
add a comment |
@lirtosiast Thanks!
– LegionMammal978
15 hours ago
@lirtosiast Thanks!
– LegionMammal978
15 hours ago
@lirtosiast Thanks!
– LegionMammal978
15 hours ago
add a comment |
up vote
4
down vote
Powershell, 150 bytes, score 163
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
Test script:
$f = {
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
}
$penalty = @(
,("Sun" , 696342)
,("Jupiter" , 69911)
,("Saturn" , 58232)
,("Uranus" , 25362)
,("Neptune" , 24622)
,("Earth" , 6371)
,("Venus" , 6052)
,("Mars" , 3390)
,("Ganymede" , 2634)
,("Titan" , 2575)
,("Mercury" , 2440)
,("Callisto" , 2410)
,("Io" , 1822)
,("Moon" , 1737)
,("Europa" , 1561)
,("Triton" , 1353)
,("Pluto" , 1186)
,("Eris" , 1163)
,("Haumea" , 816)
,("Titania" , 788)
) | % {
$s,$expected = $_
$result = &$f $s
$ratio = [Math]::Max($result/$expected, $expected/$result)
$ratio*$ratio
}
$scriptLength = $f.ToString().Length - 2 # -4 if CRLF mode
$penaltyMax = ($penalty|Measure-Object -Maximum).Maximum
$score = $scriptLength * $penaltyMax
"$score = $scriptLength * $penaltyMax"
Output:
162.113324228916 = 150 * 1.08075549485944
Explanation:
- Names contain letters only, radiuses contain digits and dots. So we can write all the data in a data string and perform a regexp search.
- The script searches for all substrings from left to right and takes the last result found.
- The input must be title-case to reduce the data string.
- The
end of line mode
is LF only.
Example:
Titania Triton Titan
-------------- ------------- -------------
T -> 1.3 T -> 1.3 T -> 1.3
Ti -> 2.5 Tr -> Ti -> 2.5
Tit -> Tri -> Tit ->
Tita -> Trit -> Tita ->
Titan -> Triton -> Titan ->
Titani -> .8
Titania ->
Result is .8 Result is 1.3 Result is 2.5
Powershell, 178 bytes, score 178
($args|% t*y|?{'Su696342J69911S58232U25362N24622Ea6371V6052Ma3390G2634Ti2575Me2440C2410I1822M1737Eu1561T1353P1186E1163H816Titani788'-cmatch"$(($y+=$_))(d+)"}|%{+$Matches.1})[-1]
add a comment |
up vote
4
down vote
Powershell, 150 bytes, score 163
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
Test script:
$f = {
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
}
$penalty = @(
,("Sun" , 696342)
,("Jupiter" , 69911)
,("Saturn" , 58232)
,("Uranus" , 25362)
,("Neptune" , 24622)
,("Earth" , 6371)
,("Venus" , 6052)
,("Mars" , 3390)
,("Ganymede" , 2634)
,("Titan" , 2575)
,("Mercury" , 2440)
,("Callisto" , 2410)
,("Io" , 1822)
,("Moon" , 1737)
,("Europa" , 1561)
,("Triton" , 1353)
,("Pluto" , 1186)
,("Eris" , 1163)
,("Haumea" , 816)
,("Titania" , 788)
) | % {
$s,$expected = $_
$result = &$f $s
$ratio = [Math]::Max($result/$expected, $expected/$result)
$ratio*$ratio
}
$scriptLength = $f.ToString().Length - 2 # -4 if CRLF mode
$penaltyMax = ($penalty|Measure-Object -Maximum).Maximum
$score = $scriptLength * $penaltyMax
"$score = $scriptLength * $penaltyMax"
Output:
162.113324228916 = 150 * 1.08075549485944
Explanation:
- Names contain letters only, radiuses contain digits and dots. So we can write all the data in a data string and perform a regexp search.
- The script searches for all substrings from left to right and takes the last result found.
- The input must be title-case to reduce the data string.
- The
end of line mode
is LF only.
Example:
Titania Triton Titan
-------------- ------------- -------------
T -> 1.3 T -> 1.3 T -> 1.3
Ti -> 2.5 Tr -> Ti -> 2.5
Tit -> Tri -> Tit ->
Tita -> Trit -> Tita ->
Titan -> Triton -> Titan ->
Titani -> .8
Titania ->
Result is .8 Result is 1.3 Result is 2.5
Powershell, 178 bytes, score 178
($args|% t*y|?{'Su696342J69911S58232U25362N24622Ea6371V6052Ma3390G2634Ti2575Me2440C2410I1822M1737Eu1561T1353P1186E1163H816Titani788'-cmatch"$(($y+=$_))(d+)"}|%{+$Matches.1})[-1]
add a comment |
up vote
4
down vote
up vote
4
down vote
Powershell, 150 bytes, score 163
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
Test script:
$f = {
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
}
$penalty = @(
,("Sun" , 696342)
,("Jupiter" , 69911)
,("Saturn" , 58232)
,("Uranus" , 25362)
,("Neptune" , 24622)
,("Earth" , 6371)
,("Venus" , 6052)
,("Mars" , 3390)
,("Ganymede" , 2634)
,("Titan" , 2575)
,("Mercury" , 2440)
,("Callisto" , 2410)
,("Io" , 1822)
,("Moon" , 1737)
,("Europa" , 1561)
,("Triton" , 1353)
,("Pluto" , 1186)
,("Eris" , 1163)
,("Haumea" , 816)
,("Titania" , 788)
) | % {
$s,$expected = $_
$result = &$f $s
$ratio = [Math]::Max($result/$expected, $expected/$result)
$ratio*$ratio
}
$scriptLength = $f.ToString().Length - 2 # -4 if CRLF mode
$penaltyMax = ($penalty|Measure-Object -Maximum).Maximum
$score = $scriptLength * $penaltyMax
"$score = $scriptLength * $penaltyMax"
Output:
162.113324228916 = 150 * 1.08075549485944
Explanation:
- Names contain letters only, radiuses contain digits and dots. So we can write all the data in a data string and perform a regexp search.
- The script searches for all substrings from left to right and takes the last result found.
- The input must be title-case to reduce the data string.
- The
end of line mode
is LF only.
Example:
Titania Triton Titan
-------------- ------------- -------------
T -> 1.3 T -> 1.3 T -> 1.3
Ti -> 2.5 Tr -> Ti -> 2.5
Tit -> Tri -> Tit ->
Tita -> Trit -> Tita ->
Titan -> Triton -> Titan ->
Titani -> .8
Titania ->
Result is .8 Result is 1.3 Result is 2.5
Powershell, 178 bytes, score 178
($args|% t*y|?{'Su696342J69911S58232U25362N24622Ea6371V6052Ma3390G2634Ti2575Me2440C2410I1822M1737Eu1561T1353P1186E1163H816Titani788'-cmatch"$(($y+=$_))(d+)"}|%{+$Matches.1})[-1]
Powershell, 150 bytes, score 163
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
Test script:
$f = {
($args|% t*y|?{'Su680J68S57U25N24Ea6V6Ma3.3G2.6Ti2.5Me2.4C2.4I1.8M1.7Eu1.5T1.3P1.2E1.1H.8Titani.8'-cmatch"$(($y+=$_))([d.]+)"}|%{1kb*$Matches.1})[-1]
}
$penalty = @(
,("Sun" , 696342)
,("Jupiter" , 69911)
,("Saturn" , 58232)
,("Uranus" , 25362)
,("Neptune" , 24622)
,("Earth" , 6371)
,("Venus" , 6052)
,("Mars" , 3390)
,("Ganymede" , 2634)
,("Titan" , 2575)
,("Mercury" , 2440)
,("Callisto" , 2410)
,("Io" , 1822)
,("Moon" , 1737)
,("Europa" , 1561)
,("Triton" , 1353)
,("Pluto" , 1186)
,("Eris" , 1163)
,("Haumea" , 816)
,("Titania" , 788)
) | % {
$s,$expected = $_
$result = &$f $s
$ratio = [Math]::Max($result/$expected, $expected/$result)
$ratio*$ratio
}
$scriptLength = $f.ToString().Length - 2 # -4 if CRLF mode
$penaltyMax = ($penalty|Measure-Object -Maximum).Maximum
$score = $scriptLength * $penaltyMax
"$score = $scriptLength * $penaltyMax"
Output:
162.113324228916 = 150 * 1.08075549485944
Explanation:
- Names contain letters only, radiuses contain digits and dots. So we can write all the data in a data string and perform a regexp search.
- The script searches for all substrings from left to right and takes the last result found.
- The input must be title-case to reduce the data string.
- The
end of line mode
is LF only.
Example:
Titania Triton Titan
-------------- ------------- -------------
T -> 1.3 T -> 1.3 T -> 1.3
Ti -> 2.5 Tr -> Ti -> 2.5
Tit -> Tri -> Tit ->
Tita -> Trit -> Tita ->
Titan -> Triton -> Titan ->
Titani -> .8
Titania ->
Result is .8 Result is 1.3 Result is 2.5
Powershell, 178 bytes, score 178
($args|% t*y|?{'Su696342J69911S58232U25362N24622Ea6371V6052Ma3390G2634Ti2575Me2440C2410I1822M1737Eu1561T1353P1186E1163H816Titani788'-cmatch"$(($y+=$_))(d+)"}|%{+$Matches.1})[-1]
edited 8 hours ago
answered 17 hours ago
mazzy
1,907313
1,907313
add a comment |
add a comment |
up vote
3
down vote
Japt, 86 bytes, score = 94
g5 ¥'i?788:[7*A³7*L6*LG²G²IIÉHÄDÑDÑCÑCÑGÄÄGÄGECC8]g`suj«a¨Ì¼và@ã/eÖô¶e©rp¤r`bU¯2)z)*L
Try it for all inputs, Calculate the score, or Check the highest error
Very similar to Olivier's original answer. Input is all lowercase.
After various improvements to the output values, the current highest error is Venus at just over 4%.
Explanation now that things are a bit more stable:
¤¥`Éa`? :If the fifth character of the input is 'i':
788 : Output 788.
: :Otherwise:
[...] : From the array representing radii
g : Get the value at the index:
`...` : In the string representing names
b : Find the first index where this string appears:
U¯2) : The first two characters of the input
z) : And divide it by two
*L : Multiply that value by 100
The string for the names is sujusaurneeavemagatimecaiomoeutrplerha
compressed using Japt's built-in compression. The numbers representing the radii are calculated like so:
My value | Actual value
---------+-------------
7 * 10 ^ 3 = 7000 * 100 = 700000 | 696342
7 * 100 = 700 * 100 = 70000 | 69911
6 * 100 = 600 * 100 = 60000 | 58232
16 * 16 = 256 * 100 = 25600 | 25362
16 * 16 = 256 * 100 = 25600 | 24622
64 = 64 * 100 = 6400 | 6371
64 - 1 = 63 * 100 = 6300 | 6052
32 + 1 = 33 * 100 = 3300 | 3390
13 * 2 = 26 * 100 = 2600 | 2634
13 * 2 = 26 * 100 = 2600 | 2575
12 * 2 = 24 * 100 = 2400 | 2440
12 * 2 = 24 * 100 = 2400 | 2410
16 + 1 + 1 = 18 * 100 = 1800 | 1822
16 + 1 = 17 * 100 = 1700 | 1737
16 = 16 * 100 = 1600 | 1561
14 = 14 * 100 = 1400 | 1353
12 = 12 * 100 = 1200 | 1186
12 = 12 * 100 = 1200 | 1163
8 = 8 * 100 = 800 | 816
788 = 788 | 788
@Oliver That's a good point. I had already noticed that the representation for Io was actually longer than the number it was encoding, so I wanted to move the values list around anyway. I'm not sure what a good way to go about finding a better order for compression would be tough, "get all permutations" isn't really runnable for 19 items.
– Kamil Drakari
yesterday
add a comment |
up vote
3
down vote
Japt, 86 bytes, score = 94
g5 ¥'i?788:[7*A³7*L6*LG²G²IIÉHÄDÑDÑCÑCÑGÄÄGÄGECC8]g`suj«a¨Ì¼và@ã/eÖô¶e©rp¤r`bU¯2)z)*L
Try it for all inputs, Calculate the score, or Check the highest error
Very similar to Olivier's original answer. Input is all lowercase.
After various improvements to the output values, the current highest error is Venus at just over 4%.
Explanation now that things are a bit more stable:
¤¥`Éa`? :If the fifth character of the input is 'i':
788 : Output 788.
: :Otherwise:
[...] : From the array representing radii
g : Get the value at the index:
`...` : In the string representing names
b : Find the first index where this string appears:
U¯2) : The first two characters of the input
z) : And divide it by two
*L : Multiply that value by 100
The string for the names is sujusaurneeavemagatimecaiomoeutrplerha
compressed using Japt's built-in compression. The numbers representing the radii are calculated like so:
My value | Actual value
---------+-------------
7 * 10 ^ 3 = 7000 * 100 = 700000 | 696342
7 * 100 = 700 * 100 = 70000 | 69911
6 * 100 = 600 * 100 = 60000 | 58232
16 * 16 = 256 * 100 = 25600 | 25362
16 * 16 = 256 * 100 = 25600 | 24622
64 = 64 * 100 = 6400 | 6371
64 - 1 = 63 * 100 = 6300 | 6052
32 + 1 = 33 * 100 = 3300 | 3390
13 * 2 = 26 * 100 = 2600 | 2634
13 * 2 = 26 * 100 = 2600 | 2575
12 * 2 = 24 * 100 = 2400 | 2440
12 * 2 = 24 * 100 = 2400 | 2410
16 + 1 + 1 = 18 * 100 = 1800 | 1822
16 + 1 = 17 * 100 = 1700 | 1737
16 = 16 * 100 = 1600 | 1561
14 = 14 * 100 = 1400 | 1353
12 = 12 * 100 = 1200 | 1186
12 = 12 * 100 = 1200 | 1163
8 = 8 * 100 = 800 | 816
788 = 788 | 788
@Oliver That's a good point. I had already noticed that the representation for Io was actually longer than the number it was encoding, so I wanted to move the values list around anyway. I'm not sure what a good way to go about finding a better order for compression would be tough, "get all permutations" isn't really runnable for 19 items.
– Kamil Drakari
yesterday
add a comment |
up vote
3
down vote
up vote
3
down vote
Japt, 86 bytes, score = 94
g5 ¥'i?788:[7*A³7*L6*LG²G²IIÉHÄDÑDÑCÑCÑGÄÄGÄGECC8]g`suj«a¨Ì¼và@ã/eÖô¶e©rp¤r`bU¯2)z)*L
Try it for all inputs, Calculate the score, or Check the highest error
Very similar to Olivier's original answer. Input is all lowercase.
After various improvements to the output values, the current highest error is Venus at just over 4%.
Explanation now that things are a bit more stable:
¤¥`Éa`? :If the fifth character of the input is 'i':
788 : Output 788.
: :Otherwise:
[...] : From the array representing radii
g : Get the value at the index:
`...` : In the string representing names
b : Find the first index where this string appears:
U¯2) : The first two characters of the input
z) : And divide it by two
*L : Multiply that value by 100
The string for the names is sujusaurneeavemagatimecaiomoeutrplerha
compressed using Japt's built-in compression. The numbers representing the radii are calculated like so:
My value | Actual value
---------+-------------
7 * 10 ^ 3 = 7000 * 100 = 700000 | 696342
7 * 100 = 700 * 100 = 70000 | 69911
6 * 100 = 600 * 100 = 60000 | 58232
16 * 16 = 256 * 100 = 25600 | 25362
16 * 16 = 256 * 100 = 25600 | 24622
64 = 64 * 100 = 6400 | 6371
64 - 1 = 63 * 100 = 6300 | 6052
32 + 1 = 33 * 100 = 3300 | 3390
13 * 2 = 26 * 100 = 2600 | 2634
13 * 2 = 26 * 100 = 2600 | 2575
12 * 2 = 24 * 100 = 2400 | 2440
12 * 2 = 24 * 100 = 2400 | 2410
16 + 1 + 1 = 18 * 100 = 1800 | 1822
16 + 1 = 17 * 100 = 1700 | 1737
16 = 16 * 100 = 1600 | 1561
14 = 14 * 100 = 1400 | 1353
12 = 12 * 100 = 1200 | 1186
12 = 12 * 100 = 1200 | 1163
8 = 8 * 100 = 800 | 816
788 = 788 | 788
Japt, 86 bytes, score = 94
g5 ¥'i?788:[7*A³7*L6*LG²G²IIÉHÄDÑDÑCÑCÑGÄÄGÄGECC8]g`suj«a¨Ì¼và@ã/eÖô¶e©rp¤r`bU¯2)z)*L
Try it for all inputs, Calculate the score, or Check the highest error
Very similar to Olivier's original answer. Input is all lowercase.
After various improvements to the output values, the current highest error is Venus at just over 4%.
Explanation now that things are a bit more stable:
¤¥`Éa`? :If the fifth character of the input is 'i':
788 : Output 788.
: :Otherwise:
[...] : From the array representing radii
g : Get the value at the index:
`...` : In the string representing names
b : Find the first index where this string appears:
U¯2) : The first two characters of the input
z) : And divide it by two
*L : Multiply that value by 100
The string for the names is sujusaurneeavemagatimecaiomoeutrplerha
compressed using Japt's built-in compression. The numbers representing the radii are calculated like so:
My value | Actual value
---------+-------------
7 * 10 ^ 3 = 7000 * 100 = 700000 | 696342
7 * 100 = 700 * 100 = 70000 | 69911
6 * 100 = 600 * 100 = 60000 | 58232
16 * 16 = 256 * 100 = 25600 | 25362
16 * 16 = 256 * 100 = 25600 | 24622
64 = 64 * 100 = 6400 | 6371
64 - 1 = 63 * 100 = 6300 | 6052
32 + 1 = 33 * 100 = 3300 | 3390
13 * 2 = 26 * 100 = 2600 | 2634
13 * 2 = 26 * 100 = 2600 | 2575
12 * 2 = 24 * 100 = 2400 | 2440
12 * 2 = 24 * 100 = 2400 | 2410
16 + 1 + 1 = 18 * 100 = 1800 | 1822
16 + 1 = 17 * 100 = 1700 | 1737
16 = 16 * 100 = 1600 | 1561
14 = 14 * 100 = 1400 | 1353
12 = 12 * 100 = 1200 | 1186
12 = 12 * 100 = 1200 | 1163
8 = 8 * 100 = 800 | 816
788 = 788 | 788
edited yesterday
answered yesterday
Kamil Drakari
2,696416
2,696416
@Oliver That's a good point. I had already noticed that the representation for Io was actually longer than the number it was encoding, so I wanted to move the values list around anyway. I'm not sure what a good way to go about finding a better order for compression would be tough, "get all permutations" isn't really runnable for 19 items.
– Kamil Drakari
yesterday
add a comment |
@Oliver That's a good point. I had already noticed that the representation for Io was actually longer than the number it was encoding, so I wanted to move the values list around anyway. I'm not sure what a good way to go about finding a better order for compression would be tough, "get all permutations" isn't really runnable for 19 items.
– Kamil Drakari
yesterday
@Oliver That's a good point. I had already noticed that the representation for Io was actually longer than the number it was encoding, so I wanted to move the values list around anyway. I'm not sure what a good way to go about finding a better order for compression would be tough, "get all permutations" isn't really runnable for 19 items.
– Kamil Drakari
yesterday
@Oliver That's a good point. I had already noticed that the representation for Io was actually longer than the number it was encoding, so I wanted to move the values list around anyway. I'm not sure what a good way to go about finding a better order for compression would be tough, "get all permutations" isn't really runnable for 19 items.
– Kamil Drakari
yesterday
add a comment |
up vote
3
down vote
Japt, 77 76 75 bytes, score = 75
First pass at this; I wanted to try a 0 penalty solution to give myself a baseline to work off. Will come back to it tomorrow to see what improvements can be made, hopefully still for 0 penalty.
Input is case-insensitive.
n35 %87%52 g"..."ò)mc
Try it or test all inputs
The "..."
represents a string containing many unprintables. The codepoints are:
32,32,15,61,11,86,696,342,25,75,699,11,33,90,63,71,24,10,24,40,253,62,60,52,32,32,8,16,11,63,32,32,32,32,58,232,17,37,135,3,246,22,18,22,26,34,7,88
To offer a quick explanation: the string gets split into chunks of 2 characters. We then index into that array using part of ovs' formula plus some index-wrapping and then map the 2 characters to their codepoints.
- Saved a byte/point thanks to ETH
54 bytes, score = 58
A port of Olivier's solution.
"ýCĄ (ᬺ!˂Fɍ"cU¤¬xc %96%49)-7 *L
Test all inputs
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the%24
:-)
– ETHproductions
23 hours ago
@ETHproductions, that doesn't seem to work
– Shaggy
14 hours ago
Here's what I was thinking
– ETHproductions
12 hours ago
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
12 hours ago
add a comment |
up vote
3
down vote
Japt, 77 76 75 bytes, score = 75
First pass at this; I wanted to try a 0 penalty solution to give myself a baseline to work off. Will come back to it tomorrow to see what improvements can be made, hopefully still for 0 penalty.
Input is case-insensitive.
n35 %87%52 g"..."ò)mc
Try it or test all inputs
The "..."
represents a string containing many unprintables. The codepoints are:
32,32,15,61,11,86,696,342,25,75,699,11,33,90,63,71,24,10,24,40,253,62,60,52,32,32,8,16,11,63,32,32,32,32,58,232,17,37,135,3,246,22,18,22,26,34,7,88
To offer a quick explanation: the string gets split into chunks of 2 characters. We then index into that array using part of ovs' formula plus some index-wrapping and then map the 2 characters to their codepoints.
- Saved a byte/point thanks to ETH
54 bytes, score = 58
A port of Olivier's solution.
"ýCĄ (ᬺ!˂Fɍ"cU¤¬xc %96%49)-7 *L
Test all inputs
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the%24
:-)
– ETHproductions
23 hours ago
@ETHproductions, that doesn't seem to work
– Shaggy
14 hours ago
Here's what I was thinking
– ETHproductions
12 hours ago
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
12 hours ago
add a comment |
up vote
3
down vote
up vote
3
down vote
Japt, 77 76 75 bytes, score = 75
First pass at this; I wanted to try a 0 penalty solution to give myself a baseline to work off. Will come back to it tomorrow to see what improvements can be made, hopefully still for 0 penalty.
Input is case-insensitive.
n35 %87%52 g"..."ò)mc
Try it or test all inputs
The "..."
represents a string containing many unprintables. The codepoints are:
32,32,15,61,11,86,696,342,25,75,699,11,33,90,63,71,24,10,24,40,253,62,60,52,32,32,8,16,11,63,32,32,32,32,58,232,17,37,135,3,246,22,18,22,26,34,7,88
To offer a quick explanation: the string gets split into chunks of 2 characters. We then index into that array using part of ovs' formula plus some index-wrapping and then map the 2 characters to their codepoints.
- Saved a byte/point thanks to ETH
54 bytes, score = 58
A port of Olivier's solution.
"ýCĄ (ᬺ!˂Fɍ"cU¤¬xc %96%49)-7 *L
Test all inputs
Japt, 77 76 75 bytes, score = 75
First pass at this; I wanted to try a 0 penalty solution to give myself a baseline to work off. Will come back to it tomorrow to see what improvements can be made, hopefully still for 0 penalty.
Input is case-insensitive.
n35 %87%52 g"..."ò)mc
Try it or test all inputs
The "..."
represents a string containing many unprintables. The codepoints are:
32,32,15,61,11,86,696,342,25,75,699,11,33,90,63,71,24,10,24,40,253,62,60,52,32,32,8,16,11,63,32,32,32,32,58,232,17,37,135,3,246,22,18,22,26,34,7,88
To offer a quick explanation: the string gets split into chunks of 2 characters. We then index into that array using part of ovs' formula plus some index-wrapping and then map the 2 characters to their codepoints.
- Saved a byte/point thanks to ETH
54 bytes, score = 58
A port of Olivier's solution.
"ýCĄ (ᬺ!˂Fɍ"cU¤¬xc %96%49)-7 *L
Test all inputs
edited 12 hours ago
answered yesterday
Shaggy
18.5k21663
18.5k21663
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the%24
:-)
– ETHproductions
23 hours ago
@ETHproductions, that doesn't seem to work
– Shaggy
14 hours ago
Here's what I was thinking
– ETHproductions
12 hours ago
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
12 hours ago
add a comment |
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the%24
:-)
– ETHproductions
23 hours ago
@ETHproductions, that doesn't seem to work
– Shaggy
14 hours ago
Here's what I was thinking
– ETHproductions
12 hours ago
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
12 hours ago
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the
%24
:-)– ETHproductions
23 hours ago
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the
%24
:-)– ETHproductions
23 hours ago
@ETHproductions, that doesn't seem to work
– Shaggy
14 hours ago
@ETHproductions, that doesn't seem to work
– Shaggy
14 hours ago
Here's what I was thinking
– ETHproductions
12 hours ago
Here's what I was thinking
– ETHproductions
12 hours ago
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
12 hours ago
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
12 hours ago
add a comment |
up vote
2
down vote
PowerShell, 203 bytes, score 203
param($a)if($a-eq'Titan'){2575;exit}(696342,69911,58232,25362,24622,6371,6052,3390,2634,2440,2410,1822,1737,1561,1353,1186,1163,816,788)["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".indexOf(-join$a[0..1])/2]
Try it online!
Very similar to Olivier's answer, now that I see it, but developed independently.
add a comment |
up vote
2
down vote
PowerShell, 203 bytes, score 203
param($a)if($a-eq'Titan'){2575;exit}(696342,69911,58232,25362,24622,6371,6052,3390,2634,2440,2410,1822,1737,1561,1353,1186,1163,816,788)["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".indexOf(-join$a[0..1])/2]
Try it online!
Very similar to Olivier's answer, now that I see it, but developed independently.
add a comment |
up vote
2
down vote
up vote
2
down vote
PowerShell, 203 bytes, score 203
param($a)if($a-eq'Titan'){2575;exit}(696342,69911,58232,25362,24622,6371,6052,3390,2634,2440,2410,1822,1737,1561,1353,1186,1163,816,788)["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".indexOf(-join$a[0..1])/2]
Try it online!
Very similar to Olivier's answer, now that I see it, but developed independently.
PowerShell, 203 bytes, score 203
param($a)if($a-eq'Titan'){2575;exit}(696342,69911,58232,25362,24622,6371,6052,3390,2634,2440,2410,1822,1737,1561,1353,1186,1163,816,788)["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".indexOf(-join$a[0..1])/2]
Try it online!
Very similar to Olivier's answer, now that I see it, but developed independently.
answered yesterday
AdmBorkBork
25.9k363226
25.9k363226
add a comment |
add a comment |
up vote
2
down vote
Python 2, 155 bytes, score = 155
lambda p:int('G11KK54222111111XXNM8MCO37WQ53YXHE93V8BIF2IMH1WU9KPU2MLN HGR'['uSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])/2::20],35)
Try it online!
Surprisingly well for this lazy solution... will look into improving as well. ;-)
add a comment |
up vote
2
down vote
Python 2, 155 bytes, score = 155
lambda p:int('G11KK54222111111XXNM8MCO37WQ53YXHE93V8BIF2IMH1WU9KPU2MLN HGR'['uSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])/2::20],35)
Try it online!
Surprisingly well for this lazy solution... will look into improving as well. ;-)
add a comment |
up vote
2
down vote
up vote
2
down vote
Python 2, 155 bytes, score = 155
lambda p:int('G11KK54222111111XXNM8MCO37WQ53YXHE93V8BIF2IMH1WU9KPU2MLN HGR'['uSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])/2::20],35)
Try it online!
Surprisingly well for this lazy solution... will look into improving as well. ;-)
Python 2, 155 bytes, score = 155
lambda p:int('G11KK54222111111XXNM8MCO37WQ53YXHE93V8BIF2IMH1WU9KPU2MLN HGR'['uSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])/2::20],35)
Try it online!
Surprisingly well for this lazy solution... will look into improving as well. ;-)
edited yesterday
answered yesterday
Erik the Outgolfer
31k429102
31k429102
add a comment |
add a comment |
up vote
2
down vote
T-SQL, 203 bytes, score = 217
SELECT IIF(v='Titan',26,SUBSTRING(value,3,4))*100
FROM i,STRING_SPLIT('Ca24,Ea64,Er12,Eu16,Ga26,Ha8,Io18,Ju699,Ma34,Me24,Mo17,Ne246,Pl12,Sa582,Su6963,Ti8,Tr14,Ur254,Ve61',',')
WHERE LEFT(v,2)=LEFT(value,2)
Line breaks are for readability only.
Input is taken via pre-existing table i with varchar column v, per our IO standards.
Joins the input table to an in-memory table on the first two characters, and returns the remaining digits x100.
Treats "Titan" as a special case using IIF
.
add a comment |
up vote
2
down vote
T-SQL, 203 bytes, score = 217
SELECT IIF(v='Titan',26,SUBSTRING(value,3,4))*100
FROM i,STRING_SPLIT('Ca24,Ea64,Er12,Eu16,Ga26,Ha8,Io18,Ju699,Ma34,Me24,Mo17,Ne246,Pl12,Sa582,Su6963,Ti8,Tr14,Ur254,Ve61',',')
WHERE LEFT(v,2)=LEFT(value,2)
Line breaks are for readability only.
Input is taken via pre-existing table i with varchar column v, per our IO standards.
Joins the input table to an in-memory table on the first two characters, and returns the remaining digits x100.
Treats "Titan" as a special case using IIF
.
add a comment |
up vote
2
down vote
up vote
2
down vote
T-SQL, 203 bytes, score = 217
SELECT IIF(v='Titan',26,SUBSTRING(value,3,4))*100
FROM i,STRING_SPLIT('Ca24,Ea64,Er12,Eu16,Ga26,Ha8,Io18,Ju699,Ma34,Me24,Mo17,Ne246,Pl12,Sa582,Su6963,Ti8,Tr14,Ur254,Ve61',',')
WHERE LEFT(v,2)=LEFT(value,2)
Line breaks are for readability only.
Input is taken via pre-existing table i with varchar column v, per our IO standards.
Joins the input table to an in-memory table on the first two characters, and returns the remaining digits x100.
Treats "Titan" as a special case using IIF
.
T-SQL, 203 bytes, score = 217
SELECT IIF(v='Titan',26,SUBSTRING(value,3,4))*100
FROM i,STRING_SPLIT('Ca24,Ea64,Er12,Eu16,Ga26,Ha8,Io18,Ju699,Ma34,Me24,Mo17,Ne246,Pl12,Sa582,Su6963,Ti8,Tr14,Ur254,Ve61',',')
WHERE LEFT(v,2)=LEFT(value,2)
Line breaks are for readability only.
Input is taken via pre-existing table i with varchar column v, per our IO standards.
Joins the input table to an in-memory table on the first two characters, and returns the remaining digits x100.
Treats "Titan" as a special case using IIF
.
answered yesterday
BradC
3,659523
3,659523
add a comment |
add a comment |
up vote
2
down vote
Ruby, 105 bytes, score 109
->n{7E5/('!)"0 r&zZ&1#}3Mfh-~~d@'[0,j=" =1&%)AM<I>2,-B#($D 7@".index((n[1,9].sum%50+34).chr)].sum-j*32)}
Try it online!
If we divide 700000 by the radii, we get a sequence which increases reasonably linearly (though rather erratically). The increments in the table below can be approximated by the ASCII values of characters. The problem with this approach is it requires the input to be decoded to a value which orders the different names by size.
A minor issue is that the difference between Eris and Haumea is quite large. Three characters ~~d
are required to encode this increment in ASCII only format. The planet-to-index string has two "ghost planet"spaces in it to pad the index.
700000/r increment from previous
0.994774
9.960407 8.965633
11.95806 1.997657
27.45612 15.49805
28.28129 0.825178
109.2987 81.0174
115.0598 5.761118
205.4106 90.3508
264.3667 58.95612
270.4241 6.057335
285.3861 14.96199
288.9386 3.552524
382.1855 93.24692
400.8877 18.70223
446.0871 45.19939
514.6652 68.57806
587.1349 72.46972
598.7463 11.61144
853.3603 254.6139
883.6827 30.32245
add a comment |
up vote
2
down vote
Ruby, 105 bytes, score 109
->n{7E5/('!)"0 r&zZ&1#}3Mfh-~~d@'[0,j=" =1&%)AM<I>2,-B#($D 7@".index((n[1,9].sum%50+34).chr)].sum-j*32)}
Try it online!
If we divide 700000 by the radii, we get a sequence which increases reasonably linearly (though rather erratically). The increments in the table below can be approximated by the ASCII values of characters. The problem with this approach is it requires the input to be decoded to a value which orders the different names by size.
A minor issue is that the difference between Eris and Haumea is quite large. Three characters ~~d
are required to encode this increment in ASCII only format. The planet-to-index string has two "ghost planet"spaces in it to pad the index.
700000/r increment from previous
0.994774
9.960407 8.965633
11.95806 1.997657
27.45612 15.49805
28.28129 0.825178
109.2987 81.0174
115.0598 5.761118
205.4106 90.3508
264.3667 58.95612
270.4241 6.057335
285.3861 14.96199
288.9386 3.552524
382.1855 93.24692
400.8877 18.70223
446.0871 45.19939
514.6652 68.57806
587.1349 72.46972
598.7463 11.61144
853.3603 254.6139
883.6827 30.32245
add a comment |
up vote
2
down vote
up vote
2
down vote
Ruby, 105 bytes, score 109
->n{7E5/('!)"0 r&zZ&1#}3Mfh-~~d@'[0,j=" =1&%)AM<I>2,-B#($D 7@".index((n[1,9].sum%50+34).chr)].sum-j*32)}
Try it online!
If we divide 700000 by the radii, we get a sequence which increases reasonably linearly (though rather erratically). The increments in the table below can be approximated by the ASCII values of characters. The problem with this approach is it requires the input to be decoded to a value which orders the different names by size.
A minor issue is that the difference between Eris and Haumea is quite large. Three characters ~~d
are required to encode this increment in ASCII only format. The planet-to-index string has two "ghost planet"spaces in it to pad the index.
700000/r increment from previous
0.994774
9.960407 8.965633
11.95806 1.997657
27.45612 15.49805
28.28129 0.825178
109.2987 81.0174
115.0598 5.761118
205.4106 90.3508
264.3667 58.95612
270.4241 6.057335
285.3861 14.96199
288.9386 3.552524
382.1855 93.24692
400.8877 18.70223
446.0871 45.19939
514.6652 68.57806
587.1349 72.46972
598.7463 11.61144
853.3603 254.6139
883.6827 30.32245
Ruby, 105 bytes, score 109
->n{7E5/('!)"0 r&zZ&1#}3Mfh-~~d@'[0,j=" =1&%)AM<I>2,-B#($D 7@".index((n[1,9].sum%50+34).chr)].sum-j*32)}
Try it online!
If we divide 700000 by the radii, we get a sequence which increases reasonably linearly (though rather erratically). The increments in the table below can be approximated by the ASCII values of characters. The problem with this approach is it requires the input to be decoded to a value which orders the different names by size.
A minor issue is that the difference between Eris and Haumea is quite large. Three characters ~~d
are required to encode this increment in ASCII only format. The planet-to-index string has two "ghost planet"spaces in it to pad the index.
700000/r increment from previous
0.994774
9.960407 8.965633
11.95806 1.997657
27.45612 15.49805
28.28129 0.825178
109.2987 81.0174
115.0598 5.761118
205.4106 90.3508
264.3667 58.95612
270.4241 6.057335
285.3861 14.96199
288.9386 3.552524
382.1855 93.24692
400.8877 18.70223
446.0871 45.19939
514.6652 68.57806
587.1349 72.46972
598.7463 11.61144
853.3603 254.6139
883.6827 30.32245
edited 3 hours ago
answered yesterday
Level River St
20.2k32579
20.2k32579
add a comment |
add a comment |
up vote
1
down vote
Charcoal, 101 bytes, score = 101
I⍘§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²⁺§θ⁰§θχγ
Try it online! Link is to verbose version of code. Explanation:
⁺§θ⁰§θχ
Take the 1st and 11th character (cyclically) of the input string and concatenate them.
⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²
Look them up in the string SuJiSrUuNtEEVVMrGnTTMcClIIMoEpToPPEiHeTa
split into pairs of characters.
§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³
Split the string m.w'fv&J|"l|"e1 c& _c Ca ;e ;* 9a 9C 31 2; 0I .7 ,N ,7 (X (<
into groups of three characters and take the corresponding group.
I⍘ ... γ
Decode the result as a base-95 number using the printable ASCII character set as the digits. Example: Io
's 11th character is I
, so we look up II
and find it's the 13th largest object and its size is 31
which maps to 19 * 95 + 17 = 1822
.
add a comment |
up vote
1
down vote
Charcoal, 101 bytes, score = 101
I⍘§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²⁺§θ⁰§θχγ
Try it online! Link is to verbose version of code. Explanation:
⁺§θ⁰§θχ
Take the 1st and 11th character (cyclically) of the input string and concatenate them.
⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²
Look them up in the string SuJiSrUuNtEEVVMrGnTTMcClIIMoEpToPPEiHeTa
split into pairs of characters.
§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³
Split the string m.w'fv&J|"l|"e1 c& _c Ca ;e ;* 9a 9C 31 2; 0I .7 ,N ,7 (X (<
into groups of three characters and take the corresponding group.
I⍘ ... γ
Decode the result as a base-95 number using the printable ASCII character set as the digits. Example: Io
's 11th character is I
, so we look up II
and find it's the 13th largest object and its size is 31
which maps to 19 * 95 + 17 = 1822
.
add a comment |
up vote
1
down vote
up vote
1
down vote
Charcoal, 101 bytes, score = 101
I⍘§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²⁺§θ⁰§θχγ
Try it online! Link is to verbose version of code. Explanation:
⁺§θ⁰§θχ
Take the 1st and 11th character (cyclically) of the input string and concatenate them.
⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²
Look them up in the string SuJiSrUuNtEEVVMrGnTTMcClIIMoEpToPPEiHeTa
split into pairs of characters.
§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³
Split the string m.w'fv&J|"l|"e1 c& _c Ca ;e ;* 9a 9C 31 2; 0I .7 ,N ,7 (X (<
into groups of three characters and take the corresponding group.
I⍘ ... γ
Decode the result as a base-95 number using the printable ASCII character set as the digits. Example: Io
's 11th character is I
, so we look up II
and find it's the 13th largest object and its size is 31
which maps to 19 * 95 + 17 = 1822
.
Charcoal, 101 bytes, score = 101
I⍘§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²⁺§θ⁰§θχγ
Try it online! Link is to verbose version of code. Explanation:
⁺§θ⁰§θχ
Take the 1st and 11th character (cyclically) of the input string and concatenate them.
⌕⪪”@/rjmq_↙§E▶νF↨oº⁷÷K⁻eDH:_Tbk¦�”²
Look them up in the string SuJiSrUuNtEEVVMrGnTTMcClIIMoEpToPPEiHeTa
split into pairs of characters.
§⪪“_″FJ⁼⦄bl≕)T‹#⊙xO-nη⁻À↓ζ↥ς§%H8H“ρj✳Hρl× S↶…|UD⎇LkfZ”³
Split the string m.w'fv&J|"l|"e1 c& _c Ca ;e ;* 9a 9C 31 2; 0I .7 ,N ,7 (X (<
into groups of three characters and take the corresponding group.
I⍘ ... γ
Decode the result as a base-95 number using the printable ASCII character set as the digits. Example: Io
's 11th character is I
, so we look up II
and find it's the 13th largest object and its size is 31
which maps to 19 * 95 + 17 = 1822
.
edited 6 hours ago
answered 7 hours ago
Neil
78.5k744175
78.5k744175
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).
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f177021%2fas-we-travel-the-universe%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
1
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
yesterday
I see the scoring has been changed to the power of 2 for the diff? In that case my 100-byte exact answer is shorter than my 70-byte approximation (which scored 91 before, but now 117..)
– Kevin Cruijssen
yesterday
@KevinCruijssen The idea behind that was to prevent extremely short answers (basically returning 1 or 2 constants) to be penalized by a reasonable factor and potentially win against more sophisticated ones.
– Arnauld
yesterday
I approve of the square in the scoring function. My previous best result was a score of 60 using 2 bytes to get
7512
for all test cases. I'll see if I dive into creating a MathGolf solution anytime soon, but it'll be hard to beat 05AB1E.– maxb
17 hours ago
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
16 hours ago