48
6
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=\left\lceil L\times\max_{1\le i \le20}\left({\max\left(\frac{A_i}{R_i},\frac{R_i}{A_i}\right)^2}\right)\right\rceil$$
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=\left\lceil 100\times{\left(\frac{1737}{1000}\right)^2}\right\rceil=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.
2Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula. – Arnauld – 2018-12-05T14:07:06.013
1I 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 – 2018-12-05T15:03:12.313
1@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 – 2018-12-05T15:10:02.527
2I 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 – 2018-12-06T10:17:14.2932@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p – Kevin Cruijssen – 2018-12-06T10:55:37.573
Isn't there still a problem with the scoring method if the program returns a large negative number? For example, if A=-1e99 then Max(A/R,R/A) would be a very small -ve number. In that way you could get an arbitrarily small score. Problem would be solved with Max(|A/R|,|R/A|) – Penguino – 2019-04-07T21:20:03.963
1@Penguino This is why "you must return positive values". – Arnauld – 2019-04-07T21:20:39.057