“As we travel the universe…”
up vote
45
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
45
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
2
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
Dec 5 at 14:07
1
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
Dec 5 at 15:03
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
Dec 5 at 15:10
2
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
Dec 6 at 10:17
2
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
Dec 6 at 10:55
add a comment |
up vote
45
down vote
favorite
up vote
45
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 Dec 6 at 12:37
asked Dec 5 at 14:05
Arnauld
71.6k688299
71.6k688299
2
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
Dec 5 at 14:07
1
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
Dec 5 at 15:03
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
Dec 5 at 15:10
2
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
Dec 6 at 10:17
2
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
Dec 6 at 10:55
add a comment |
2
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
Dec 5 at 14:07
1
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
Dec 5 at 15:03
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
Dec 5 at 15:10
2
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
Dec 6 at 10:17
2
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
Dec 6 at 10:55
2
2
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
Dec 5 at 14:07
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
Dec 5 at 14:07
1
1
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
Dec 5 at 15:03
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
Dec 5 at 15:03
1
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
Dec 5 at 15:10
@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
Dec 5 at 15:10
2
2
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
Dec 6 at 10:17
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
Dec 6 at 10:17
2
2
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
Dec 6 at 10:55
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
Dec 6 at 10:55
add a comment |
20 Answers
20
active
oldest
votes
up vote
26
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.
3
That's all you need to know about KPI :)
– mazzy
Dec 5 at 15:59
12
Why is this getting so many votes?!
– Shaggy
Dec 5 at 23:43
11
@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
Dec 6 at 8:43
5
It does fit the question's criterias though. I think people vote it because it's so obvious, many wouldn't have thought about it. It also denotes a challenge with a flawed rating system, if it can be abused that way.
– Elcan
Dec 6 at 10:37
8
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
Dec 6 at 15:58
|
show 6 more comments
up vote
24
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
Dec 6 at 3:38
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
Dec 6 at 13:21
er, "then take the result mod n".
– lirtosiast
Dec 6 at 23:47
@lirtosiast Done.
– Dennis♦
Dec 11 at 21:08
add a comment |
up vote
19
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..
3
96 bytes & 103 score with the same output.
– Kevin Cruijssen
Dec 5 at 18:54
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
Dec 5 at 19:42
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
Dec 5 at 20:12
@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
Dec 6 at 9:39
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
Dec 6 at 10:08
|
show 2 more comments
up vote
9
down vote
Wolfram Language 114 103 97 88 86 82 bytes. score = 114 103 97 89 87 83 points
(#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/._String->507)1.61&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 6 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. In the case of "Haumea", the value, 816.27 (i.e. 507*1.61), is returned.
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.
1
Another wolfram built in. Just like detecting downgoats
– OganM
Dec 6 at 23:46
I would've answered this but I don't know the wolfram language lol
– Quintec
Dec 7 at 1:29
Actually, this requires internet connection too (tested on 10.2)
– user202729
Dec 9 at 6:03
@user202729, Your last two, helpful, suggestions are now integrated. Use of curated entities, such as astronomical bodies, does indeed require internet connection.
– DavidC
Dec 9 at 14:24
@user202729 Built-in datasets are allowed, even if they have to be downloaded.
– Dennis♦
Dec 12 at 3:11
|
show 1 more 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
5
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
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
Dec 6 at 10:36
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
Dec 6 at 10:52
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.
1
Hmm. Doesn't this count as using the internet? Unless Mathematica actually does contain the entire WolframAlpha engine
– ASCII-only
Dec 9 at 4:37
@ASCII-only I mean, Mathematica's datasets are allowed, and theWolframAlpha
function has been used at least four times...
– LegionMammal978
Dec 9 at 18:04
Hmm. Seems kinda like an arbitrary decision, what's stopping other languages from adding search engine functions? IMO datasets are a bit different - downloading all of them is just so massive that a central server gives it to you when needed
– ASCII-only
Dec 10 at 1:10
@ASCII-only If you're worried, you can always post a question on Meta.
– LegionMammal978
Dec 10 at 2:05
@leg In that case the data can be used offline after downloading. In this case, it's not.
– user202729
Dec 11 at 5:50
add a comment |
up vote
3
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
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
Dec 5 at 21:55
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
Dec 6 at 4:14
@ETHproductions, that doesn't seem to work
– Shaggy
Dec 6 at 12:41
Here's what I was thinking
– ETHproductions
Dec 6 at 14:50
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
Dec 6 at 15:03
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
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
2
down vote
Jelly, 28 bytes, score = 31
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ1.1*
This uses a configurable hashing built-in that I added to Jelly at @lirtosiast's suggestion.
Input is in titlecase, output is the power of 1.1 with the least error.
Try it online!
How it works
This answer consists of merely two parts.
- First,
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ
uses the new built-in to map each of the 20 possible inputs to 15 different integers. - Then,
1.1*
elevates 1.1 to the computed power.
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘
is a literal; every non-quote character is replaced by it's 0-based index in Jelly's code page, yielding $[95, 95, 169, 55, 242], [82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$.
The hashing built-in ḥ
first maps $[95, 95, 169, 55, 242]$ to an integer by incrementing each number, then treating the result as the bijective base-250 digits integer and adding $1$. This yields $376510639244$.
By halving and flooring this integer until the result is $0$, we get the sequence $[376510639244, 188255319622, 94127659811, 47063829905, dots, 5, 2, 1, 0]$, which has the forward differences $[188255319622, 94127659811, 47063829906, dots, 3, 1, 1]$.
Next, we generate 64 64-bit integers by applying SHAKE256-4096 to the string representation of the internal representation of ḥ
's right argument, then chopping the resulting 4096 bits into 64 64-bit chunks.
ḥ
now computes the dot product of the 39 differences and the first 39 generated 64-bit integers, modulo $2^{64}$. This yields an integer in $[0, 2^{64})$.
The list $[82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$ has length 15, so we multiply the generated integer by 15 and take the 64 higher bits of the result. This yields an integer in $[0, 15)$, which we use to index into the list.
To find the appropriate hash configuration, I've used a brute-forcer in C that is part of the Jelly repo.
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
Swift 4, 225 bytes, score = 241
Probably golfable a bunch more (maybe in the "Ga-Me-Ca" area?), but Swift is not often used (for a reason, maybe.)
func b(i:String){print(i=="Titan" ?2575:["Su":6963,"Ju":699,"Sa":582,"Ur":253,"Ne":246,"Ea":63,"Ve":60,"Ma":33,"Ga":26,"Me":24,"Ca":24,"Io":18,"Mo":17,"Eu":16,"Tr":14,"Pl":12,"Er":12,"Ha":8,"Ti":8][String(i.prefix(2))]!*100)}
and ungolfed
func size(ofAstralObject object: String) {
let objectToRadius = // Map size/100 of all objects to the first two chars
["Su":6963,
"Ju":699,
"Sa":582,
"Ur":253,
"Ne":246,
"Ea":63,
"Ve":60,
"Ma":33,
"Ga":26,
"Me":24,
"Ca":24,
"Io":18,
"Mo":17,
"Eu":16,
"Tr":14,
"Pl":12,
"Er":12,
"Ha":8,
"Ti":8] // Ti is Titania, while Titan is treated differently
print(object == "Titan" ?
2575 : // If "Titan", print the exact size
objectToRadius[String(i.prefix(2))]!*100 // get the size from the map and multiply by 100
)
}
Try It Online!
I tried different "key sizes" for the map, but of course 1 has many clashes and using three chars doesn't give me i=="Titan" ?2575:
's 17 chars, since there's "Io" to manage (and it'll take more than 3 chars, I think).
add a comment |
up vote
1
down vote
JavaScript (ES6), 152 bytes, score = 163
Well, it's a pretty standard solution, but I enjoyed the challenge anyway!
s=>s=='Titan'?2575:[6963,699,582,254,246,64,60,34,26,24,24,18,17,16,14,12,12,8,8]["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".match(s[0]+s[1]).index/2]*100
My Score:
Max. penalty ratio = 1.07068 for Triton
Score = ceil(152 x 1.07068) = 163
Try it Online!
add a comment |
up vote
1
down vote
FALSE, 152 bytes, Score = 563
[911*.]^$0[~][1+^]#$$2=$4=8=||[2 0!]?$3=[764 0!]?$5=[$$69=86=|$[6]?~[2]?0!]?$6=[$$83=85=|$[46]?~[$72=$[1]?~[2]?]?0!]?$7=[$84=$[1]?~[52]?0!]?
Lazy answer using word lengths and first letters but my excuse is that I'm using a weird language
Try it online! (copy paste the code, hit show and then run)
[911*.] {defines a function that multiplies a number by 911 and then prints it}
^$0[~][1+^]# {counts the length of the name as it's input, also records the first char}
$$2=$4=8=||[1 0!]? {if the name is 2, 4, or 8 chars long print 911*2 (0! calls the function)}
$3=[764 0!]? {if name is 3 long print 911*764}
$5=[$$69=86=|$[6]?~[2]?0!]? {5 long? print 911*6 if it starts with E or V, otherwise *2}
$6=[$$83=85=|$[46]?~[ {6 long? print 911*46 if it starts with S or U, otherwise:}
$72=$[1]?~[2]? {if name starts with H print 911*1 else *2
]?0!]?
$7=[$84=$[1]?~[26]?0!]? {7 long? print 1822*1 if it starts with NT otherwise *26 (for jupiter}
My results:
Sun : 696004.00 penalty ratio = (696342.00 / 696004.00 )² = 1.00097
Jupiter : 47372.00 penalty ratio = (69911.00 / 47372.00 )² = 2.17795
Saturn : 41906.00 penalty ratio = (58232.00 / 41906.00 )² = 1.93095
Uranus : 41906.00 penalty ratio = (41906.00 / 25362.00 )² = 2.73014
Neptune : 47372.00 penalty ratio = (47372.00 / 24622.00 )² = 3.70166
Earth : 5466.00 penalty ratio = (6371.00 / 5466.00 )² = 1.35855
Venus : 5466.00 penalty ratio = (6052.00 / 5466.00 )² = 1.22591
Mars : 1822.00 penalty ratio = (3390.00 / 1822.00 )² = 3.46181
Ganymede : 1822.00 penalty ratio = (2634.00 / 1822.00 )² = 2.08994
Titan : 1822.00 penalty ratio = (2575.00 / 1822.00 )² = 1.99737
Mercury : 1822.00 penalty ratio = (2440.00 / 1822.00 )² = 1.79342
Callisto : 1822.00 penalty ratio = (2410.00 / 1822.00 )² = 1.74959
Io : 1822.00 penalty ratio = (1822.00 / 1822.00 )² = 1.00000
Moon : 1822.00 penalty ratio = (1822.00 / 1737.00 )² = 1.10026
Europa : 1822.00 penalty ratio = (1822.00 / 1561.00 )² = 1.36236
Triton : 1822.00 penalty ratio = (1822.00 / 1353.00 )² = 1.81343
Pluto : 1822.00 penalty ratio = (1822.00 / 1186.00 )² = 2.36008
Eris : 1822.00 penalty ratio = (1822.00 / 1163.00 )² = 2.45435
Haumea : 911.00 penalty ratio = (911.00 / 816.00 )² = 1.24640
Titania : 911.00 penalty ratio = (911.00 / 788.00 )² = 1.33655
Max. penalty ratio = 3.70166 for Neptune
Score = ceil(152 x 3.70166) = 563
New contributor
It seems like the optimal multiplier for your current code is $1634$.
– Arnauld
Dec 12 at 2:36
I updated it to use half of 1822 (911) instead to I could make a special case for Haumea, so this advice doesn't work anymore. I tried using 817 (half of 1634) but it wasn't good. If you want to work your magic and find the new most optimal number feel free.
– Terjerber
Dec 12 at 2:52
add a comment |
up vote
0
down vote
Python 2, 89 bytes, Score = 234
lambda(p):39**4/'zzuSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])**2.18
Try it online!
Most answers posted appear to have used a "encode/decode" strategy. I wondered how well I could do by estimating the diameter of celestial bodies using a simple equation. It's been a fun exercise, but the moderate byte savings are more than made up for by the accuracy penalty.
The core of this solution is the estimating equation:
Radius = 39**4/x**2.18
where x is twice the rank order of the radius of the body.
I generate the value of x based on the input string using a modification of @Erik the Outgolfer's Python 2 solution. I saved a few bytes on his code by recasting my equations to work with [2..40] instead of [1..20].
The code for generating rank orders takes up more than 2/3 of the bytes of the whole solution. If anyone has a more compact way of generating ranks, this solution could be shortened further. Because of the accuracy penalty (around 2.6), the score would improve quite a bit.
Generating the Equation
I used statistical methods to search for simple equations to estimate the size of each body based on its rank. In part following up on the insights in @Level River St's Ruby solution and generalizing, I settled on equations of the form:
Radius = A/(Rank)**B
Working in R, I used linear models on the log of the radii to develop initial estimates, and then used non-linear optimization, seeding the optimization with the results of the linear models, to search for solutions that minimized the penalty function specified in the problem.
The estimated value of A in the above equation is seven digits, so I searched for a simple expression to save a couple of bytes. I looked for expressions of the form
x**y
for two digit x and 1 digit y (for a total of five bytes, saving two bytes, or about five points, given the penalty) that was not too different from the optimum value of A and did not inflate the penalty much, and ended up with the (otherwise inexplicable):
39**4
The scoring algorithm really seems to hurt this method-- I'd guess that it would do better under L2 or L1 norm of error. Though you're wasting bytes storing the names anyway.
– lirtosiast
Dec 12 at 6:15
@lirtosiast Agree to both points. Interestingly, a least squares fit (L2 norm) is pretty good under this scoring algorithm too. It has only about 5% worse penalty than the best equation I found. On storing the names : I could not figure out a more compact way to generate an ascending sequence of numbers from text input. The modulo arithmetic approaches taken in other answers randomize the order.
– CCB60
Dec 12 at 14:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
20 Answers
20
active
oldest
votes
20 Answers
20
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
26
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.
3
That's all you need to know about KPI :)
– mazzy
Dec 5 at 15:59
12
Why is this getting so many votes?!
– Shaggy
Dec 5 at 23:43
11
@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
Dec 6 at 8:43
5
It does fit the question's criterias though. I think people vote it because it's so obvious, many wouldn't have thought about it. It also denotes a challenge with a flawed rating system, if it can be abused that way.
– Elcan
Dec 6 at 10:37
8
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
Dec 6 at 15:58
|
show 6 more comments
up vote
26
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.
3
That's all you need to know about KPI :)
– mazzy
Dec 5 at 15:59
12
Why is this getting so many votes?!
– Shaggy
Dec 5 at 23:43
11
@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
Dec 6 at 8:43
5
It does fit the question's criterias though. I think people vote it because it's so obvious, many wouldn't have thought about it. It also denotes a challenge with a flawed rating system, if it can be abused that way.
– Elcan
Dec 6 at 10:37
8
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
Dec 6 at 15:58
|
show 6 more comments
up vote
26
down vote
up vote
26
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 Dec 5 at 14:56
AdmBorkBork
26k364226
26k364226
3
That's all you need to know about KPI :)
– mazzy
Dec 5 at 15:59
12
Why is this getting so many votes?!
– Shaggy
Dec 5 at 23:43
11
@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
Dec 6 at 8:43
5
It does fit the question's criterias though. I think people vote it because it's so obvious, many wouldn't have thought about it. It also denotes a challenge with a flawed rating system, if it can be abused that way.
– Elcan
Dec 6 at 10:37
8
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
Dec 6 at 15:58
|
show 6 more comments
3
That's all you need to know about KPI :)
– mazzy
Dec 5 at 15:59
12
Why is this getting so many votes?!
– Shaggy
Dec 5 at 23:43
11
@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
Dec 6 at 8:43
5
It does fit the question's criterias though. I think people vote it because it's so obvious, many wouldn't have thought about it. It also denotes a challenge with a flawed rating system, if it can be abused that way.
– Elcan
Dec 6 at 10:37
8
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
Dec 6 at 15:58
3
3
That's all you need to know about KPI :)
– mazzy
Dec 5 at 15:59
That's all you need to know about KPI :)
– mazzy
Dec 5 at 15:59
12
12
Why is this getting so many votes?!
– Shaggy
Dec 5 at 23:43
Why is this getting so many votes?!
– Shaggy
Dec 5 at 23:43
11
11
@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
Dec 6 at 8:43
@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
Dec 6 at 8:43
5
5
It does fit the question's criterias though. I think people vote it because it's so obvious, many wouldn't have thought about it. It also denotes a challenge with a flawed rating system, if it can be abused that way.
– Elcan
Dec 6 at 10:37
It does fit the question's criterias though. I think people vote it because it's so obvious, many wouldn't have thought about it. It also denotes a challenge with a flawed rating system, if it can be abused that way.
– Elcan
Dec 6 at 10:37
8
8
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
Dec 6 at 15:58
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
Dec 6 at 15:58
|
show 6 more comments
up vote
24
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
Dec 6 at 3:38
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
Dec 6 at 13:21
er, "then take the result mod n".
– lirtosiast
Dec 6 at 23:47
@lirtosiast Done.
– Dennis♦
Dec 11 at 21:08
add a comment |
up vote
24
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
Dec 6 at 3:38
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
Dec 6 at 13:21
er, "then take the result mod n".
– lirtosiast
Dec 6 at 23:47
@lirtosiast Done.
– Dennis♦
Dec 11 at 21:08
add a comment |
up vote
24
down vote
up vote
24
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 Dec 6 at 13:19
answered Dec 5 at 16:02
Dennis♦
186k32295734
186k32295734
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
Dec 6 at 3:38
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
Dec 6 at 13:21
er, "then take the result mod n".
– lirtosiast
Dec 6 at 23:47
@lirtosiast Done.
– Dennis♦
Dec 11 at 21:08
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
Dec 6 at 3:38
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
Dec 6 at 13:21
er, "then take the result mod n".
– lirtosiast
Dec 6 at 23:47
@lirtosiast Done.
– Dennis♦
Dec 11 at 21:08
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
Dec 6 at 3:38
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
Dec 6 at 3:38
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
Dec 6 at 13:21
@lirtosiast That sounds interesting. I don't think I understand what you mean by one that also is modular though.
– Dennis♦
Dec 6 at 13:21
er, "then take the result mod n".
– lirtosiast
Dec 6 at 23:47
er, "then take the result mod n".
– lirtosiast
Dec 6 at 23:47
@lirtosiast Done.
– Dennis♦
Dec 11 at 21:08
@lirtosiast Done.
– Dennis♦
Dec 11 at 21:08
add a comment |
up vote
19
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..
3
96 bytes & 103 score with the same output.
– Kevin Cruijssen
Dec 5 at 18:54
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
Dec 5 at 19:42
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
Dec 5 at 20:12
@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
Dec 6 at 9:39
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
Dec 6 at 10:08
|
show 2 more comments
up vote
19
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..
3
96 bytes & 103 score with the same output.
– Kevin Cruijssen
Dec 5 at 18:54
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
Dec 5 at 19:42
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
Dec 5 at 20:12
@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
Dec 6 at 9:39
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
Dec 6 at 10:08
|
show 2 more comments
up vote
19
down vote
up vote
19
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 Dec 6 at 11:09
answered Dec 5 at 15:14
Olivier Grégoire
8,70711843
8,70711843
3
96 bytes & 103 score with the same output.
– Kevin Cruijssen
Dec 5 at 18:54
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
Dec 5 at 19:42
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
Dec 5 at 20:12
@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
Dec 6 at 9:39
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
Dec 6 at 10:08
|
show 2 more comments
3
96 bytes & 103 score with the same output.
– Kevin Cruijssen
Dec 5 at 18:54
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
Dec 5 at 19:42
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
Dec 5 at 20:12
@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
Dec 6 at 9:39
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
Dec 6 at 10:08
3
3
96 bytes & 103 score with the same output.
– Kevin Cruijssen
Dec 5 at 18:54
96 bytes & 103 score with the same output.
– Kevin Cruijssen
Dec 5 at 18:54
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
Dec 5 at 19:42
Thanks @KevinCruijssen! That's a nice golf, using unicode characters in a string instead of an array of decimal values. :-)
– Olivier Grégoire
Dec 5 at 19:42
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
Dec 5 at 20:12
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
Dec 5 at 20:12
@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
Dec 6 at 9:39
@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
Dec 6 at 9:39
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
Dec 6 at 10:08
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
Dec 6 at 10:08
|
show 2 more comments
up vote
9
down vote
Wolfram Language 114 103 97 88 86 82 bytes. score = 114 103 97 89 87 83 points
(#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/._String->507)1.61&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 6 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. In the case of "Haumea", the value, 816.27 (i.e. 507*1.61), is returned.
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.
1
Another wolfram built in. Just like detecting downgoats
– OganM
Dec 6 at 23:46
I would've answered this but I don't know the wolfram language lol
– Quintec
Dec 7 at 1:29
Actually, this requires internet connection too (tested on 10.2)
– user202729
Dec 9 at 6:03
@user202729, Your last two, helpful, suggestions are now integrated. Use of curated entities, such as astronomical bodies, does indeed require internet connection.
– DavidC
Dec 9 at 14:24
@user202729 Built-in datasets are allowed, even if they have to be downloaded.
– Dennis♦
Dec 12 at 3:11
|
show 1 more comment
up vote
9
down vote
Wolfram Language 114 103 97 88 86 82 bytes. score = 114 103 97 89 87 83 points
(#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/._String->507)1.61&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 6 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. In the case of "Haumea", the value, 816.27 (i.e. 507*1.61), is returned.
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.
1
Another wolfram built in. Just like detecting downgoats
– OganM
Dec 6 at 23:46
I would've answered this but I don't know the wolfram language lol
– Quintec
Dec 7 at 1:29
Actually, this requires internet connection too (tested on 10.2)
– user202729
Dec 9 at 6:03
@user202729, Your last two, helpful, suggestions are now integrated. Use of curated entities, such as astronomical bodies, does indeed require internet connection.
– DavidC
Dec 9 at 14:24
@user202729 Built-in datasets are allowed, even if they have to be downloaded.
– Dennis♦
Dec 12 at 3:11
|
show 1 more comment
up vote
9
down vote
up vote
9
down vote
Wolfram Language 114 103 97 88 86 82 bytes. score = 114 103 97 89 87 83 points
(#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/._String->507)1.61&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 6 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. In the case of "Haumea", the value, 816.27 (i.e. 507*1.61), is returned.
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 82 bytes. score = 114 103 97 89 87 83 points
(#&@@EntityValue[Interpreter["AstronomicalObject"]@#,"Radius"]/._String->507)1.61&
At least 6 points saved thanks to Dennis
, several more thanks to lirtosiast
, and 6 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. In the case of "Haumea", the value, 816.27 (i.e. 507*1.61), is returned.
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 Dec 9 at 14:22
answered Dec 5 at 17:09
DavidC
23.7k243102
23.7k243102
1
Another wolfram built in. Just like detecting downgoats
– OganM
Dec 6 at 23:46
I would've answered this but I don't know the wolfram language lol
– Quintec
Dec 7 at 1:29
Actually, this requires internet connection too (tested on 10.2)
– user202729
Dec 9 at 6:03
@user202729, Your last two, helpful, suggestions are now integrated. Use of curated entities, such as astronomical bodies, does indeed require internet connection.
– DavidC
Dec 9 at 14:24
@user202729 Built-in datasets are allowed, even if they have to be downloaded.
– Dennis♦
Dec 12 at 3:11
|
show 1 more comment
1
Another wolfram built in. Just like detecting downgoats
– OganM
Dec 6 at 23:46
I would've answered this but I don't know the wolfram language lol
– Quintec
Dec 7 at 1:29
Actually, this requires internet connection too (tested on 10.2)
– user202729
Dec 9 at 6:03
@user202729, Your last two, helpful, suggestions are now integrated. Use of curated entities, such as astronomical bodies, does indeed require internet connection.
– DavidC
Dec 9 at 14:24
@user202729 Built-in datasets are allowed, even if they have to be downloaded.
– Dennis♦
Dec 12 at 3:11
1
1
Another wolfram built in. Just like detecting downgoats
– OganM
Dec 6 at 23:46
Another wolfram built in. Just like detecting downgoats
– OganM
Dec 6 at 23:46
I would've answered this but I don't know the wolfram language lol
– Quintec
Dec 7 at 1:29
I would've answered this but I don't know the wolfram language lol
– Quintec
Dec 7 at 1:29
Actually, this requires internet connection too (tested on 10.2)
– user202729
Dec 9 at 6:03
Actually, this requires internet connection too (tested on 10.2)
– user202729
Dec 9 at 6:03
@user202729, Your last two, helpful, suggestions are now integrated. Use of curated entities, such as astronomical bodies, does indeed require internet connection.
– DavidC
Dec 9 at 14:24
@user202729, Your last two, helpful, suggestions are now integrated. Use of curated entities, such as astronomical bodies, does indeed require internet connection.
– DavidC
Dec 9 at 14:24
@user202729 Built-in datasets are allowed, even if they have to be downloaded.
– Dennis♦
Dec 12 at 3:11
@user202729 Built-in datasets are allowed, even if they have to be downloaded.
– Dennis♦
Dec 12 at 3:11
|
show 1 more 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 Dec 5 at 15:58
answered Dec 5 at 15:50
ovs
18.7k21059
18.7k21059
add a comment |
add a comment |
up vote
5
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
5
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
5
down vote
up vote
5
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 Dec 6 at 18:44
answered Dec 6 at 10:05
mazzy
2,0151314
2,0151314
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
Dec 6 at 10:36
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
Dec 6 at 10:52
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
Dec 6 at 10:36
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
Dec 6 at 10:52
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 Dec 6 at 10:52
answered Dec 5 at 15:01
Kevin Cruijssen
35.4k554186
35.4k554186
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
Dec 6 at 10:36
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
Dec 6 at 10:52
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
Dec 6 at 10:36
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
Dec 6 at 10:52
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
Dec 6 at 10:36
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
Dec 6 at 10:36
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
Dec 6 at 10:52
@OlivierGrégoire Thanks for the heads-up. -6 score and -7 bytes. :)
– Kevin Cruijssen
Dec 6 at 10:52
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.
1
Hmm. Doesn't this count as using the internet? Unless Mathematica actually does contain the entire WolframAlpha engine
– ASCII-only
Dec 9 at 4:37
@ASCII-only I mean, Mathematica's datasets are allowed, and theWolframAlpha
function has been used at least four times...
– LegionMammal978
Dec 9 at 18:04
Hmm. Seems kinda like an arbitrary decision, what's stopping other languages from adding search engine functions? IMO datasets are a bit different - downloading all of them is just so massive that a central server gives it to you when needed
– ASCII-only
Dec 10 at 1:10
@ASCII-only If you're worried, you can always post a question on Meta.
– LegionMammal978
Dec 10 at 2:05
@leg In that case the data can be used offline after downloading. In this case, it's not.
– user202729
Dec 11 at 5:50
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.
1
Hmm. Doesn't this count as using the internet? Unless Mathematica actually does contain the entire WolframAlpha engine
– ASCII-only
Dec 9 at 4:37
@ASCII-only I mean, Mathematica's datasets are allowed, and theWolframAlpha
function has been used at least four times...
– LegionMammal978
Dec 9 at 18:04
Hmm. Seems kinda like an arbitrary decision, what's stopping other languages from adding search engine functions? IMO datasets are a bit different - downloading all of them is just so massive that a central server gives it to you when needed
– ASCII-only
Dec 10 at 1:10
@ASCII-only If you're worried, you can always post a question on Meta.
– LegionMammal978
Dec 10 at 2:05
@leg In that case the data can be used offline after downloading. In this case, it's not.
– user202729
Dec 11 at 5:50
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 Dec 6 at 12:11
answered Dec 6 at 2:59
LegionMammal978
15.1k41852
15.1k41852
1
Hmm. Doesn't this count as using the internet? Unless Mathematica actually does contain the entire WolframAlpha engine
– ASCII-only
Dec 9 at 4:37
@ASCII-only I mean, Mathematica's datasets are allowed, and theWolframAlpha
function has been used at least four times...
– LegionMammal978
Dec 9 at 18:04
Hmm. Seems kinda like an arbitrary decision, what's stopping other languages from adding search engine functions? IMO datasets are a bit different - downloading all of them is just so massive that a central server gives it to you when needed
– ASCII-only
Dec 10 at 1:10
@ASCII-only If you're worried, you can always post a question on Meta.
– LegionMammal978
Dec 10 at 2:05
@leg In that case the data can be used offline after downloading. In this case, it's not.
– user202729
Dec 11 at 5:50
add a comment |
1
Hmm. Doesn't this count as using the internet? Unless Mathematica actually does contain the entire WolframAlpha engine
– ASCII-only
Dec 9 at 4:37
@ASCII-only I mean, Mathematica's datasets are allowed, and theWolframAlpha
function has been used at least four times...
– LegionMammal978
Dec 9 at 18:04
Hmm. Seems kinda like an arbitrary decision, what's stopping other languages from adding search engine functions? IMO datasets are a bit different - downloading all of them is just so massive that a central server gives it to you when needed
– ASCII-only
Dec 10 at 1:10
@ASCII-only If you're worried, you can always post a question on Meta.
– LegionMammal978
Dec 10 at 2:05
@leg In that case the data can be used offline after downloading. In this case, it's not.
– user202729
Dec 11 at 5:50
1
1
Hmm. Doesn't this count as using the internet? Unless Mathematica actually does contain the entire WolframAlpha engine
– ASCII-only
Dec 9 at 4:37
Hmm. Doesn't this count as using the internet? Unless Mathematica actually does contain the entire WolframAlpha engine
– ASCII-only
Dec 9 at 4:37
@ASCII-only I mean, Mathematica's datasets are allowed, and the
WolframAlpha
function has been used at least four times...– LegionMammal978
Dec 9 at 18:04
@ASCII-only I mean, Mathematica's datasets are allowed, and the
WolframAlpha
function has been used at least four times...– LegionMammal978
Dec 9 at 18:04
Hmm. Seems kinda like an arbitrary decision, what's stopping other languages from adding search engine functions? IMO datasets are a bit different - downloading all of them is just so massive that a central server gives it to you when needed
– ASCII-only
Dec 10 at 1:10
Hmm. Seems kinda like an arbitrary decision, what's stopping other languages from adding search engine functions? IMO datasets are a bit different - downloading all of them is just so massive that a central server gives it to you when needed
– ASCII-only
Dec 10 at 1:10
@ASCII-only If you're worried, you can always post a question on Meta.
– LegionMammal978
Dec 10 at 2:05
@ASCII-only If you're worried, you can always post a question on Meta.
– LegionMammal978
Dec 10 at 2:05
@leg In that case the data can be used offline after downloading. In this case, it's not.
– user202729
Dec 11 at 5:50
@leg In that case the data can be used offline after downloading. In this case, it's not.
– user202729
Dec 11 at 5:50
add a comment |
up vote
3
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
3
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
3
down vote
up vote
3
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 Dec 5 at 15:55
answered Dec 5 at 15:48
Erik the Outgolfer
31.1k429102
31.1k429102
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
Dec 5 at 21:55
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
Dec 5 at 21:55
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 Dec 5 at 22:13
answered Dec 5 at 17:06
Kamil Drakari
2,931416
2,931416
@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
Dec 5 at 21:55
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
Dec 5 at 21:55
@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
Dec 5 at 21:55
@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
Dec 5 at 21:55
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
Dec 6 at 4:14
@ETHproductions, that doesn't seem to work
– Shaggy
Dec 6 at 12:41
Here's what I was thinking
– ETHproductions
Dec 6 at 14:50
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
Dec 6 at 15:03
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
Dec 6 at 4:14
@ETHproductions, that doesn't seem to work
– Shaggy
Dec 6 at 12:41
Here's what I was thinking
– ETHproductions
Dec 6 at 14:50
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
Dec 6 at 15:03
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 Dec 6 at 15:08
answered Dec 5 at 22:46
Shaggy
18.7k21663
18.7k21663
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the%24
:-)
– ETHproductions
Dec 6 at 4:14
@ETHproductions, that doesn't seem to work
– Shaggy
Dec 6 at 12:41
Here's what I was thinking
– ETHproductions
Dec 6 at 14:50
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
Dec 6 at 15:03
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
Dec 6 at 4:14
@ETHproductions, that doesn't seem to work
– Shaggy
Dec 6 at 12:41
Here's what I was thinking
– ETHproductions
Dec 6 at 14:50
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
Dec 6 at 15:03
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the
%24
:-)– ETHproductions
Dec 6 at 4:14
I think you can save a byte by moving the first entry (#23) to the end where it belongs, and removing the
%24
:-)– ETHproductions
Dec 6 at 4:14
@ETHproductions, that doesn't seem to work
– Shaggy
Dec 6 at 12:41
@ETHproductions, that doesn't seem to work
– Shaggy
Dec 6 at 12:41
Here's what I was thinking
– ETHproductions
Dec 6 at 14:50
Here's what I was thinking
– ETHproductions
Dec 6 at 14:50
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
Dec 6 at 15:03
@ETHproductions: Ah, yes, just twigged myself that I'd need to add a placeholder element to the start of the array. Thanks.
– Shaggy
Dec 6 at 15:03
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 Dec 5 at 15:35
AdmBorkBork
26k364226
26k364226
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 Dec 5 at 23:19
BradC
3,679523
3,679523
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 Dec 7 at 0:16
answered Dec 6 at 2:09
Level River St
20.2k32579
20.2k32579
add a comment |
add a comment |
up vote
2
down vote
Jelly, 28 bytes, score = 31
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ1.1*
This uses a configurable hashing built-in that I added to Jelly at @lirtosiast's suggestion.
Input is in titlecase, output is the power of 1.1 with the least error.
Try it online!
How it works
This answer consists of merely two parts.
- First,
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ
uses the new built-in to map each of the 20 possible inputs to 15 different integers. - Then,
1.1*
elevates 1.1 to the computed power.
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘
is a literal; every non-quote character is replaced by it's 0-based index in Jelly's code page, yielding $[95, 95, 169, 55, 242], [82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$.
The hashing built-in ḥ
first maps $[95, 95, 169, 55, 242]$ to an integer by incrementing each number, then treating the result as the bijective base-250 digits integer and adding $1$. This yields $376510639244$.
By halving and flooring this integer until the result is $0$, we get the sequence $[376510639244, 188255319622, 94127659811, 47063829905, dots, 5, 2, 1, 0]$, which has the forward differences $[188255319622, 94127659811, 47063829906, dots, 3, 1, 1]$.
Next, we generate 64 64-bit integers by applying SHAKE256-4096 to the string representation of the internal representation of ḥ
's right argument, then chopping the resulting 4096 bits into 64 64-bit chunks.
ḥ
now computes the dot product of the 39 differences and the first 39 generated 64-bit integers, modulo $2^{64}$. This yields an integer in $[0, 2^{64})$.
The list $[82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$ has length 15, so we multiply the generated integer by 15 and take the 64 higher bits of the result. This yields an integer in $[0, 15)$, which we use to index into the list.
To find the appropriate hash configuration, I've used a brute-forcer in C that is part of the Jelly repo.
add a comment |
up vote
2
down vote
Jelly, 28 bytes, score = 31
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ1.1*
This uses a configurable hashing built-in that I added to Jelly at @lirtosiast's suggestion.
Input is in titlecase, output is the power of 1.1 with the least error.
Try it online!
How it works
This answer consists of merely two parts.
- First,
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ
uses the new built-in to map each of the 20 possible inputs to 15 different integers. - Then,
1.1*
elevates 1.1 to the computed power.
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘
is a literal; every non-quote character is replaced by it's 0-based index in Jelly's code page, yielding $[95, 95, 169, 55, 242], [82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$.
The hashing built-in ḥ
first maps $[95, 95, 169, 55, 242]$ to an integer by incrementing each number, then treating the result as the bijective base-250 digits integer and adding $1$. This yields $376510639244$.
By halving and flooring this integer until the result is $0$, we get the sequence $[376510639244, 188255319622, 94127659811, 47063829905, dots, 5, 2, 1, 0]$, which has the forward differences $[188255319622, 94127659811, 47063829906, dots, 3, 1, 1]$.
Next, we generate 64 64-bit integers by applying SHAKE256-4096 to the string representation of the internal representation of ḥ
's right argument, then chopping the resulting 4096 bits into 64 64-bit chunks.
ḥ
now computes the dot product of the 39 differences and the first 39 generated 64-bit integers, modulo $2^{64}$. This yields an integer in $[0, 2^{64})$.
The list $[82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$ has length 15, so we multiply the generated integer by 15 and take the 64 higher bits of the result. This yields an integer in $[0, 15)$, which we use to index into the list.
To find the appropriate hash configuration, I've used a brute-forcer in C that is part of the Jelly repo.
add a comment |
up vote
2
down vote
up vote
2
down vote
Jelly, 28 bytes, score = 31
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ1.1*
This uses a configurable hashing built-in that I added to Jelly at @lirtosiast's suggestion.
Input is in titlecase, output is the power of 1.1 with the least error.
Try it online!
How it works
This answer consists of merely two parts.
- First,
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ
uses the new built-in to map each of the 20 possible inputs to 15 different integers. - Then,
1.1*
elevates 1.1 to the computed power.
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘
is a literal; every non-quote character is replaced by it's 0-based index in Jelly's code page, yielding $[95, 95, 169, 55, 242], [82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$.
The hashing built-in ḥ
first maps $[95, 95, 169, 55, 242]$ to an integer by incrementing each number, then treating the result as the bijective base-250 digits integer and adding $1$. This yields $376510639244$.
By halving and flooring this integer until the result is $0$, we get the sequence $[376510639244, 188255319622, 94127659811, 47063829905, dots, 5, 2, 1, 0]$, which has the forward differences $[188255319622, 94127659811, 47063829906, dots, 3, 1, 1]$.
Next, we generate 64 64-bit integers by applying SHAKE256-4096 to the string representation of the internal representation of ḥ
's right argument, then chopping the resulting 4096 bits into 64 64-bit chunks.
ḥ
now computes the dot product of the 39 differences and the first 39 generated 64-bit integers, modulo $2^{64}$. This yields an integer in $[0, 2^{64})$.
The list $[82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$ has length 15, so we multiply the generated integer by 15 and take the 64 higher bits of the result. This yields an integer in $[0, 15)$, which we use to index into the list.
To find the appropriate hash configuration, I've used a brute-forcer in C that is part of the Jelly repo.
Jelly, 28 bytes, score = 31
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ1.1*
This uses a configurable hashing built-in that I added to Jelly at @lirtosiast's suggestion.
Input is in titlecase, output is the power of 1.1 with the least error.
Try it online!
How it works
This answer consists of merely two parts.
- First,
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘ḥ
uses the new built-in to map each of the 20 possible inputs to 15 different integers. - Then,
1.1*
elevates 1.1 to the computed power.
“__ʋ7ṗ“RUu⁽NMsOSJj[FL‘
is a literal; every non-quote character is replaced by it's 0-based index in Jelly's code page, yielding $[95, 95, 169, 55, 242], [82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$.
The hashing built-in ḥ
first maps $[95, 95, 169, 55, 242]$ to an integer by incrementing each number, then treating the result as the bijective base-250 digits integer and adding $1$. This yields $376510639244$.
By halving and flooring this integer until the result is $0$, we get the sequence $[376510639244, 188255319622, 94127659811, 47063829905, dots, 5, 2, 1, 0]$, which has the forward differences $[188255319622, 94127659811, 47063829906, dots, 3, 1, 1]$.
Next, we generate 64 64-bit integers by applying SHAKE256-4096 to the string representation of the internal representation of ḥ
's right argument, then chopping the resulting 4096 bits into 64 64-bit chunks.
ḥ
now computes the dot product of the 39 differences and the first 39 generated 64-bit integers, modulo $2^{64}$. This yields an integer in $[0, 2^{64})$.
The list $[82, 85, 117, 141, 78, 77, 92, 115, 79, 83, 74, 106, 91, 70, 76]$ has length 15, so we multiply the generated integer by 15 and take the 64 higher bits of the result. This yields an integer in $[0, 15)$, which we use to index into the list.
To find the appropriate hash configuration, I've used a brute-forcer in C that is part of the Jelly repo.
answered Dec 11 at 21:07
Dennis♦
186k32295734
186k32295734
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 Dec 6 at 21:03
answered Dec 6 at 19:56
Neil
78.9k744175
78.9k744175
add a comment |
add a comment |
up vote
1
down vote
Swift 4, 225 bytes, score = 241
Probably golfable a bunch more (maybe in the "Ga-Me-Ca" area?), but Swift is not often used (for a reason, maybe.)
func b(i:String){print(i=="Titan" ?2575:["Su":6963,"Ju":699,"Sa":582,"Ur":253,"Ne":246,"Ea":63,"Ve":60,"Ma":33,"Ga":26,"Me":24,"Ca":24,"Io":18,"Mo":17,"Eu":16,"Tr":14,"Pl":12,"Er":12,"Ha":8,"Ti":8][String(i.prefix(2))]!*100)}
and ungolfed
func size(ofAstralObject object: String) {
let objectToRadius = // Map size/100 of all objects to the first two chars
["Su":6963,
"Ju":699,
"Sa":582,
"Ur":253,
"Ne":246,
"Ea":63,
"Ve":60,
"Ma":33,
"Ga":26,
"Me":24,
"Ca":24,
"Io":18,
"Mo":17,
"Eu":16,
"Tr":14,
"Pl":12,
"Er":12,
"Ha":8,
"Ti":8] // Ti is Titania, while Titan is treated differently
print(object == "Titan" ?
2575 : // If "Titan", print the exact size
objectToRadius[String(i.prefix(2))]!*100 // get the size from the map and multiply by 100
)
}
Try It Online!
I tried different "key sizes" for the map, but of course 1 has many clashes and using three chars doesn't give me i=="Titan" ?2575:
's 17 chars, since there's "Io" to manage (and it'll take more than 3 chars, I think).
add a comment |
up vote
1
down vote
Swift 4, 225 bytes, score = 241
Probably golfable a bunch more (maybe in the "Ga-Me-Ca" area?), but Swift is not often used (for a reason, maybe.)
func b(i:String){print(i=="Titan" ?2575:["Su":6963,"Ju":699,"Sa":582,"Ur":253,"Ne":246,"Ea":63,"Ve":60,"Ma":33,"Ga":26,"Me":24,"Ca":24,"Io":18,"Mo":17,"Eu":16,"Tr":14,"Pl":12,"Er":12,"Ha":8,"Ti":8][String(i.prefix(2))]!*100)}
and ungolfed
func size(ofAstralObject object: String) {
let objectToRadius = // Map size/100 of all objects to the first two chars
["Su":6963,
"Ju":699,
"Sa":582,
"Ur":253,
"Ne":246,
"Ea":63,
"Ve":60,
"Ma":33,
"Ga":26,
"Me":24,
"Ca":24,
"Io":18,
"Mo":17,
"Eu":16,
"Tr":14,
"Pl":12,
"Er":12,
"Ha":8,
"Ti":8] // Ti is Titania, while Titan is treated differently
print(object == "Titan" ?
2575 : // If "Titan", print the exact size
objectToRadius[String(i.prefix(2))]!*100 // get the size from the map and multiply by 100
)
}
Try It Online!
I tried different "key sizes" for the map, but of course 1 has many clashes and using three chars doesn't give me i=="Titan" ?2575:
's 17 chars, since there's "Io" to manage (and it'll take more than 3 chars, I think).
add a comment |
up vote
1
down vote
up vote
1
down vote
Swift 4, 225 bytes, score = 241
Probably golfable a bunch more (maybe in the "Ga-Me-Ca" area?), but Swift is not often used (for a reason, maybe.)
func b(i:String){print(i=="Titan" ?2575:["Su":6963,"Ju":699,"Sa":582,"Ur":253,"Ne":246,"Ea":63,"Ve":60,"Ma":33,"Ga":26,"Me":24,"Ca":24,"Io":18,"Mo":17,"Eu":16,"Tr":14,"Pl":12,"Er":12,"Ha":8,"Ti":8][String(i.prefix(2))]!*100)}
and ungolfed
func size(ofAstralObject object: String) {
let objectToRadius = // Map size/100 of all objects to the first two chars
["Su":6963,
"Ju":699,
"Sa":582,
"Ur":253,
"Ne":246,
"Ea":63,
"Ve":60,
"Ma":33,
"Ga":26,
"Me":24,
"Ca":24,
"Io":18,
"Mo":17,
"Eu":16,
"Tr":14,
"Pl":12,
"Er":12,
"Ha":8,
"Ti":8] // Ti is Titania, while Titan is treated differently
print(object == "Titan" ?
2575 : // If "Titan", print the exact size
objectToRadius[String(i.prefix(2))]!*100 // get the size from the map and multiply by 100
)
}
Try It Online!
I tried different "key sizes" for the map, but of course 1 has many clashes and using three chars doesn't give me i=="Titan" ?2575:
's 17 chars, since there's "Io" to manage (and it'll take more than 3 chars, I think).
Swift 4, 225 bytes, score = 241
Probably golfable a bunch more (maybe in the "Ga-Me-Ca" area?), but Swift is not often used (for a reason, maybe.)
func b(i:String){print(i=="Titan" ?2575:["Su":6963,"Ju":699,"Sa":582,"Ur":253,"Ne":246,"Ea":63,"Ve":60,"Ma":33,"Ga":26,"Me":24,"Ca":24,"Io":18,"Mo":17,"Eu":16,"Tr":14,"Pl":12,"Er":12,"Ha":8,"Ti":8][String(i.prefix(2))]!*100)}
and ungolfed
func size(ofAstralObject object: String) {
let objectToRadius = // Map size/100 of all objects to the first two chars
["Su":6963,
"Ju":699,
"Sa":582,
"Ur":253,
"Ne":246,
"Ea":63,
"Ve":60,
"Ma":33,
"Ga":26,
"Me":24,
"Ca":24,
"Io":18,
"Mo":17,
"Eu":16,
"Tr":14,
"Pl":12,
"Er":12,
"Ha":8,
"Ti":8] // Ti is Titania, while Titan is treated differently
print(object == "Titan" ?
2575 : // If "Titan", print the exact size
objectToRadius[String(i.prefix(2))]!*100 // get the size from the map and multiply by 100
)
}
Try It Online!
I tried different "key sizes" for the map, but of course 1 has many clashes and using three chars doesn't give me i=="Titan" ?2575:
's 17 chars, since there's "Io" to manage (and it'll take more than 3 chars, I think).
answered Dec 7 at 12:27
Simone Chelo
45348
45348
add a comment |
add a comment |
up vote
1
down vote
JavaScript (ES6), 152 bytes, score = 163
Well, it's a pretty standard solution, but I enjoyed the challenge anyway!
s=>s=='Titan'?2575:[6963,699,582,254,246,64,60,34,26,24,24,18,17,16,14,12,12,8,8]["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".match(s[0]+s[1]).index/2]*100
My Score:
Max. penalty ratio = 1.07068 for Triton
Score = ceil(152 x 1.07068) = 163
Try it Online!
add a comment |
up vote
1
down vote
JavaScript (ES6), 152 bytes, score = 163
Well, it's a pretty standard solution, but I enjoyed the challenge anyway!
s=>s=='Titan'?2575:[6963,699,582,254,246,64,60,34,26,24,24,18,17,16,14,12,12,8,8]["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".match(s[0]+s[1]).index/2]*100
My Score:
Max. penalty ratio = 1.07068 for Triton
Score = ceil(152 x 1.07068) = 163
Try it Online!
add a comment |
up vote
1
down vote
up vote
1
down vote
JavaScript (ES6), 152 bytes, score = 163
Well, it's a pretty standard solution, but I enjoyed the challenge anyway!
s=>s=='Titan'?2575:[6963,699,582,254,246,64,60,34,26,24,24,18,17,16,14,12,12,8,8]["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".match(s[0]+s[1]).index/2]*100
My Score:
Max. penalty ratio = 1.07068 for Triton
Score = ceil(152 x 1.07068) = 163
Try it Online!
JavaScript (ES6), 152 bytes, score = 163
Well, it's a pretty standard solution, but I enjoyed the challenge anyway!
s=>s=='Titan'?2575:[6963,699,582,254,246,64,60,34,26,24,24,18,17,16,14,12,12,8,8]["SuJuSaUrNeEaVeMaGaMeCaIoMoEuTrPlErHaTi".match(s[0]+s[1]).index/2]*100
My Score:
Max. penalty ratio = 1.07068 for Triton
Score = ceil(152 x 1.07068) = 163
Try it Online!
answered Dec 11 at 11:18
zruF
595
595
add a comment |
add a comment |
up vote
1
down vote
FALSE, 152 bytes, Score = 563
[911*.]^$0[~][1+^]#$$2=$4=8=||[2 0!]?$3=[764 0!]?$5=[$$69=86=|$[6]?~[2]?0!]?$6=[$$83=85=|$[46]?~[$72=$[1]?~[2]?]?0!]?$7=[$84=$[1]?~[52]?0!]?
Lazy answer using word lengths and first letters but my excuse is that I'm using a weird language
Try it online! (copy paste the code, hit show and then run)
[911*.] {defines a function that multiplies a number by 911 and then prints it}
^$0[~][1+^]# {counts the length of the name as it's input, also records the first char}
$$2=$4=8=||[1 0!]? {if the name is 2, 4, or 8 chars long print 911*2 (0! calls the function)}
$3=[764 0!]? {if name is 3 long print 911*764}
$5=[$$69=86=|$[6]?~[2]?0!]? {5 long? print 911*6 if it starts with E or V, otherwise *2}
$6=[$$83=85=|$[46]?~[ {6 long? print 911*46 if it starts with S or U, otherwise:}
$72=$[1]?~[2]? {if name starts with H print 911*1 else *2
]?0!]?
$7=[$84=$[1]?~[26]?0!]? {7 long? print 1822*1 if it starts with NT otherwise *26 (for jupiter}
My results:
Sun : 696004.00 penalty ratio = (696342.00 / 696004.00 )² = 1.00097
Jupiter : 47372.00 penalty ratio = (69911.00 / 47372.00 )² = 2.17795
Saturn : 41906.00 penalty ratio = (58232.00 / 41906.00 )² = 1.93095
Uranus : 41906.00 penalty ratio = (41906.00 / 25362.00 )² = 2.73014
Neptune : 47372.00 penalty ratio = (47372.00 / 24622.00 )² = 3.70166
Earth : 5466.00 penalty ratio = (6371.00 / 5466.00 )² = 1.35855
Venus : 5466.00 penalty ratio = (6052.00 / 5466.00 )² = 1.22591
Mars : 1822.00 penalty ratio = (3390.00 / 1822.00 )² = 3.46181
Ganymede : 1822.00 penalty ratio = (2634.00 / 1822.00 )² = 2.08994
Titan : 1822.00 penalty ratio = (2575.00 / 1822.00 )² = 1.99737
Mercury : 1822.00 penalty ratio = (2440.00 / 1822.00 )² = 1.79342
Callisto : 1822.00 penalty ratio = (2410.00 / 1822.00 )² = 1.74959
Io : 1822.00 penalty ratio = (1822.00 / 1822.00 )² = 1.00000
Moon : 1822.00 penalty ratio = (1822.00 / 1737.00 )² = 1.10026
Europa : 1822.00 penalty ratio = (1822.00 / 1561.00 )² = 1.36236
Triton : 1822.00 penalty ratio = (1822.00 / 1353.00 )² = 1.81343
Pluto : 1822.00 penalty ratio = (1822.00 / 1186.00 )² = 2.36008
Eris : 1822.00 penalty ratio = (1822.00 / 1163.00 )² = 2.45435
Haumea : 911.00 penalty ratio = (911.00 / 816.00 )² = 1.24640
Titania : 911.00 penalty ratio = (911.00 / 788.00 )² = 1.33655
Max. penalty ratio = 3.70166 for Neptune
Score = ceil(152 x 3.70166) = 563
New contributor
It seems like the optimal multiplier for your current code is $1634$.
– Arnauld
Dec 12 at 2:36
I updated it to use half of 1822 (911) instead to I could make a special case for Haumea, so this advice doesn't work anymore. I tried using 817 (half of 1634) but it wasn't good. If you want to work your magic and find the new most optimal number feel free.
– Terjerber
Dec 12 at 2:52
add a comment |
up vote
1
down vote
FALSE, 152 bytes, Score = 563
[911*.]^$0[~][1+^]#$$2=$4=8=||[2 0!]?$3=[764 0!]?$5=[$$69=86=|$[6]?~[2]?0!]?$6=[$$83=85=|$[46]?~[$72=$[1]?~[2]?]?0!]?$7=[$84=$[1]?~[52]?0!]?
Lazy answer using word lengths and first letters but my excuse is that I'm using a weird language
Try it online! (copy paste the code, hit show and then run)
[911*.] {defines a function that multiplies a number by 911 and then prints it}
^$0[~][1+^]# {counts the length of the name as it's input, also records the first char}
$$2=$4=8=||[1 0!]? {if the name is 2, 4, or 8 chars long print 911*2 (0! calls the function)}
$3=[764 0!]? {if name is 3 long print 911*764}
$5=[$$69=86=|$[6]?~[2]?0!]? {5 long? print 911*6 if it starts with E or V, otherwise *2}
$6=[$$83=85=|$[46]?~[ {6 long? print 911*46 if it starts with S or U, otherwise:}
$72=$[1]?~[2]? {if name starts with H print 911*1 else *2
]?0!]?
$7=[$84=$[1]?~[26]?0!]? {7 long? print 1822*1 if it starts with NT otherwise *26 (for jupiter}
My results:
Sun : 696004.00 penalty ratio = (696342.00 / 696004.00 )² = 1.00097
Jupiter : 47372.00 penalty ratio = (69911.00 / 47372.00 )² = 2.17795
Saturn : 41906.00 penalty ratio = (58232.00 / 41906.00 )² = 1.93095
Uranus : 41906.00 penalty ratio = (41906.00 / 25362.00 )² = 2.73014
Neptune : 47372.00 penalty ratio = (47372.00 / 24622.00 )² = 3.70166
Earth : 5466.00 penalty ratio = (6371.00 / 5466.00 )² = 1.35855
Venus : 5466.00 penalty ratio = (6052.00 / 5466.00 )² = 1.22591
Mars : 1822.00 penalty ratio = (3390.00 / 1822.00 )² = 3.46181
Ganymede : 1822.00 penalty ratio = (2634.00 / 1822.00 )² = 2.08994
Titan : 1822.00 penalty ratio = (2575.00 / 1822.00 )² = 1.99737
Mercury : 1822.00 penalty ratio = (2440.00 / 1822.00 )² = 1.79342
Callisto : 1822.00 penalty ratio = (2410.00 / 1822.00 )² = 1.74959
Io : 1822.00 penalty ratio = (1822.00 / 1822.00 )² = 1.00000
Moon : 1822.00 penalty ratio = (1822.00 / 1737.00 )² = 1.10026
Europa : 1822.00 penalty ratio = (1822.00 / 1561.00 )² = 1.36236
Triton : 1822.00 penalty ratio = (1822.00 / 1353.00 )² = 1.81343
Pluto : 1822.00 penalty ratio = (1822.00 / 1186.00 )² = 2.36008
Eris : 1822.00 penalty ratio = (1822.00 / 1163.00 )² = 2.45435
Haumea : 911.00 penalty ratio = (911.00 / 816.00 )² = 1.24640
Titania : 911.00 penalty ratio = (911.00 / 788.00 )² = 1.33655
Max. penalty ratio = 3.70166 for Neptune
Score = ceil(152 x 3.70166) = 563
New contributor
It seems like the optimal multiplier for your current code is $1634$.
– Arnauld
Dec 12 at 2:36
I updated it to use half of 1822 (911) instead to I could make a special case for Haumea, so this advice doesn't work anymore. I tried using 817 (half of 1634) but it wasn't good. If you want to work your magic and find the new most optimal number feel free.
– Terjerber
Dec 12 at 2:52
add a comment |
up vote
1
down vote
up vote
1
down vote
FALSE, 152 bytes, Score = 563
[911*.]^$0[~][1+^]#$$2=$4=8=||[2 0!]?$3=[764 0!]?$5=[$$69=86=|$[6]?~[2]?0!]?$6=[$$83=85=|$[46]?~[$72=$[1]?~[2]?]?0!]?$7=[$84=$[1]?~[52]?0!]?
Lazy answer using word lengths and first letters but my excuse is that I'm using a weird language
Try it online! (copy paste the code, hit show and then run)
[911*.] {defines a function that multiplies a number by 911 and then prints it}
^$0[~][1+^]# {counts the length of the name as it's input, also records the first char}
$$2=$4=8=||[1 0!]? {if the name is 2, 4, or 8 chars long print 911*2 (0! calls the function)}
$3=[764 0!]? {if name is 3 long print 911*764}
$5=[$$69=86=|$[6]?~[2]?0!]? {5 long? print 911*6 if it starts with E or V, otherwise *2}
$6=[$$83=85=|$[46]?~[ {6 long? print 911*46 if it starts with S or U, otherwise:}
$72=$[1]?~[2]? {if name starts with H print 911*1 else *2
]?0!]?
$7=[$84=$[1]?~[26]?0!]? {7 long? print 1822*1 if it starts with NT otherwise *26 (for jupiter}
My results:
Sun : 696004.00 penalty ratio = (696342.00 / 696004.00 )² = 1.00097
Jupiter : 47372.00 penalty ratio = (69911.00 / 47372.00 )² = 2.17795
Saturn : 41906.00 penalty ratio = (58232.00 / 41906.00 )² = 1.93095
Uranus : 41906.00 penalty ratio = (41906.00 / 25362.00 )² = 2.73014
Neptune : 47372.00 penalty ratio = (47372.00 / 24622.00 )² = 3.70166
Earth : 5466.00 penalty ratio = (6371.00 / 5466.00 )² = 1.35855
Venus : 5466.00 penalty ratio = (6052.00 / 5466.00 )² = 1.22591
Mars : 1822.00 penalty ratio = (3390.00 / 1822.00 )² = 3.46181
Ganymede : 1822.00 penalty ratio = (2634.00 / 1822.00 )² = 2.08994
Titan : 1822.00 penalty ratio = (2575.00 / 1822.00 )² = 1.99737
Mercury : 1822.00 penalty ratio = (2440.00 / 1822.00 )² = 1.79342
Callisto : 1822.00 penalty ratio = (2410.00 / 1822.00 )² = 1.74959
Io : 1822.00 penalty ratio = (1822.00 / 1822.00 )² = 1.00000
Moon : 1822.00 penalty ratio = (1822.00 / 1737.00 )² = 1.10026
Europa : 1822.00 penalty ratio = (1822.00 / 1561.00 )² = 1.36236
Triton : 1822.00 penalty ratio = (1822.00 / 1353.00 )² = 1.81343
Pluto : 1822.00 penalty ratio = (1822.00 / 1186.00 )² = 2.36008
Eris : 1822.00 penalty ratio = (1822.00 / 1163.00 )² = 2.45435
Haumea : 911.00 penalty ratio = (911.00 / 816.00 )² = 1.24640
Titania : 911.00 penalty ratio = (911.00 / 788.00 )² = 1.33655
Max. penalty ratio = 3.70166 for Neptune
Score = ceil(152 x 3.70166) = 563
New contributor
FALSE, 152 bytes, Score = 563
[911*.]^$0[~][1+^]#$$2=$4=8=||[2 0!]?$3=[764 0!]?$5=[$$69=86=|$[6]?~[2]?0!]?$6=[$$83=85=|$[46]?~[$72=$[1]?~[2]?]?0!]?$7=[$84=$[1]?~[52]?0!]?
Lazy answer using word lengths and first letters but my excuse is that I'm using a weird language
Try it online! (copy paste the code, hit show and then run)
[911*.] {defines a function that multiplies a number by 911 and then prints it}
^$0[~][1+^]# {counts the length of the name as it's input, also records the first char}
$$2=$4=8=||[1 0!]? {if the name is 2, 4, or 8 chars long print 911*2 (0! calls the function)}
$3=[764 0!]? {if name is 3 long print 911*764}
$5=[$$69=86=|$[6]?~[2]?0!]? {5 long? print 911*6 if it starts with E or V, otherwise *2}
$6=[$$83=85=|$[46]?~[ {6 long? print 911*46 if it starts with S or U, otherwise:}
$72=$[1]?~[2]? {if name starts with H print 911*1 else *2
]?0!]?
$7=[$84=$[1]?~[26]?0!]? {7 long? print 1822*1 if it starts with NT otherwise *26 (for jupiter}
My results:
Sun : 696004.00 penalty ratio = (696342.00 / 696004.00 )² = 1.00097
Jupiter : 47372.00 penalty ratio = (69911.00 / 47372.00 )² = 2.17795
Saturn : 41906.00 penalty ratio = (58232.00 / 41906.00 )² = 1.93095
Uranus : 41906.00 penalty ratio = (41906.00 / 25362.00 )² = 2.73014
Neptune : 47372.00 penalty ratio = (47372.00 / 24622.00 )² = 3.70166
Earth : 5466.00 penalty ratio = (6371.00 / 5466.00 )² = 1.35855
Venus : 5466.00 penalty ratio = (6052.00 / 5466.00 )² = 1.22591
Mars : 1822.00 penalty ratio = (3390.00 / 1822.00 )² = 3.46181
Ganymede : 1822.00 penalty ratio = (2634.00 / 1822.00 )² = 2.08994
Titan : 1822.00 penalty ratio = (2575.00 / 1822.00 )² = 1.99737
Mercury : 1822.00 penalty ratio = (2440.00 / 1822.00 )² = 1.79342
Callisto : 1822.00 penalty ratio = (2410.00 / 1822.00 )² = 1.74959
Io : 1822.00 penalty ratio = (1822.00 / 1822.00 )² = 1.00000
Moon : 1822.00 penalty ratio = (1822.00 / 1737.00 )² = 1.10026
Europa : 1822.00 penalty ratio = (1822.00 / 1561.00 )² = 1.36236
Triton : 1822.00 penalty ratio = (1822.00 / 1353.00 )² = 1.81343
Pluto : 1822.00 penalty ratio = (1822.00 / 1186.00 )² = 2.36008
Eris : 1822.00 penalty ratio = (1822.00 / 1163.00 )² = 2.45435
Haumea : 911.00 penalty ratio = (911.00 / 816.00 )² = 1.24640
Titania : 911.00 penalty ratio = (911.00 / 788.00 )² = 1.33655
Max. penalty ratio = 3.70166 for Neptune
Score = ceil(152 x 3.70166) = 563
New contributor
edited Dec 12 at 2:50
New contributor
answered Dec 12 at 2:19
Terjerber
514
514
New contributor
New contributor
It seems like the optimal multiplier for your current code is $1634$.
– Arnauld
Dec 12 at 2:36
I updated it to use half of 1822 (911) instead to I could make a special case for Haumea, so this advice doesn't work anymore. I tried using 817 (half of 1634) but it wasn't good. If you want to work your magic and find the new most optimal number feel free.
– Terjerber
Dec 12 at 2:52
add a comment |
It seems like the optimal multiplier for your current code is $1634$.
– Arnauld
Dec 12 at 2:36
I updated it to use half of 1822 (911) instead to I could make a special case for Haumea, so this advice doesn't work anymore. I tried using 817 (half of 1634) but it wasn't good. If you want to work your magic and find the new most optimal number feel free.
– Terjerber
Dec 12 at 2:52
It seems like the optimal multiplier for your current code is $1634$.
– Arnauld
Dec 12 at 2:36
It seems like the optimal multiplier for your current code is $1634$.
– Arnauld
Dec 12 at 2:36
I updated it to use half of 1822 (911) instead to I could make a special case for Haumea, so this advice doesn't work anymore. I tried using 817 (half of 1634) but it wasn't good. If you want to work your magic and find the new most optimal number feel free.
– Terjerber
Dec 12 at 2:52
I updated it to use half of 1822 (911) instead to I could make a special case for Haumea, so this advice doesn't work anymore. I tried using 817 (half of 1634) but it wasn't good. If you want to work your magic and find the new most optimal number feel free.
– Terjerber
Dec 12 at 2:52
add a comment |
up vote
0
down vote
Python 2, 89 bytes, Score = 234
lambda(p):39**4/'zzuSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])**2.18
Try it online!
Most answers posted appear to have used a "encode/decode" strategy. I wondered how well I could do by estimating the diameter of celestial bodies using a simple equation. It's been a fun exercise, but the moderate byte savings are more than made up for by the accuracy penalty.
The core of this solution is the estimating equation:
Radius = 39**4/x**2.18
where x is twice the rank order of the radius of the body.
I generate the value of x based on the input string using a modification of @Erik the Outgolfer's Python 2 solution. I saved a few bytes on his code by recasting my equations to work with [2..40] instead of [1..20].
The code for generating rank orders takes up more than 2/3 of the bytes of the whole solution. If anyone has a more compact way of generating ranks, this solution could be shortened further. Because of the accuracy penalty (around 2.6), the score would improve quite a bit.
Generating the Equation
I used statistical methods to search for simple equations to estimate the size of each body based on its rank. In part following up on the insights in @Level River St's Ruby solution and generalizing, I settled on equations of the form:
Radius = A/(Rank)**B
Working in R, I used linear models on the log of the radii to develop initial estimates, and then used non-linear optimization, seeding the optimization with the results of the linear models, to search for solutions that minimized the penalty function specified in the problem.
The estimated value of A in the above equation is seven digits, so I searched for a simple expression to save a couple of bytes. I looked for expressions of the form
x**y
for two digit x and 1 digit y (for a total of five bytes, saving two bytes, or about five points, given the penalty) that was not too different from the optimum value of A and did not inflate the penalty much, and ended up with the (otherwise inexplicable):
39**4
The scoring algorithm really seems to hurt this method-- I'd guess that it would do better under L2 or L1 norm of error. Though you're wasting bytes storing the names anyway.
– lirtosiast
Dec 12 at 6:15
@lirtosiast Agree to both points. Interestingly, a least squares fit (L2 norm) is pretty good under this scoring algorithm too. It has only about 5% worse penalty than the best equation I found. On storing the names : I could not figure out a more compact way to generate an ascending sequence of numbers from text input. The modulo arithmetic approaches taken in other answers randomize the order.
– CCB60
Dec 12 at 14:13
add a comment |
up vote
0
down vote
Python 2, 89 bytes, Score = 234
lambda(p):39**4/'zzuSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])**2.18
Try it online!
Most answers posted appear to have used a "encode/decode" strategy. I wondered how well I could do by estimating the diameter of celestial bodies using a simple equation. It's been a fun exercise, but the moderate byte savings are more than made up for by the accuracy penalty.
The core of this solution is the estimating equation:
Radius = 39**4/x**2.18
where x is twice the rank order of the radius of the body.
I generate the value of x based on the input string using a modification of @Erik the Outgolfer's Python 2 solution. I saved a few bytes on his code by recasting my equations to work with [2..40] instead of [1..20].
The code for generating rank orders takes up more than 2/3 of the bytes of the whole solution. If anyone has a more compact way of generating ranks, this solution could be shortened further. Because of the accuracy penalty (around 2.6), the score would improve quite a bit.
Generating the Equation
I used statistical methods to search for simple equations to estimate the size of each body based on its rank. In part following up on the insights in @Level River St's Ruby solution and generalizing, I settled on equations of the form:
Radius = A/(Rank)**B
Working in R, I used linear models on the log of the radii to develop initial estimates, and then used non-linear optimization, seeding the optimization with the results of the linear models, to search for solutions that minimized the penalty function specified in the problem.
The estimated value of A in the above equation is seven digits, so I searched for a simple expression to save a couple of bytes. I looked for expressions of the form
x**y
for two digit x and 1 digit y (for a total of five bytes, saving two bytes, or about five points, given the penalty) that was not too different from the optimum value of A and did not inflate the penalty much, and ended up with the (otherwise inexplicable):
39**4
The scoring algorithm really seems to hurt this method-- I'd guess that it would do better under L2 or L1 norm of error. Though you're wasting bytes storing the names anyway.
– lirtosiast
Dec 12 at 6:15
@lirtosiast Agree to both points. Interestingly, a least squares fit (L2 norm) is pretty good under this scoring algorithm too. It has only about 5% worse penalty than the best equation I found. On storing the names : I could not figure out a more compact way to generate an ascending sequence of numbers from text input. The modulo arithmetic approaches taken in other answers randomize the order.
– CCB60
Dec 12 at 14:13
add a comment |
up vote
0
down vote
up vote
0
down vote
Python 2, 89 bytes, Score = 234
lambda(p):39**4/'zzuSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])**2.18
Try it online!
Most answers posted appear to have used a "encode/decode" strategy. I wondered how well I could do by estimating the diameter of celestial bodies using a simple equation. It's been a fun exercise, but the moderate byte savings are more than made up for by the accuracy penalty.
The core of this solution is the estimating equation:
Radius = 39**4/x**2.18
where x is twice the rank order of the radius of the body.
I generate the value of x based on the input string using a modification of @Erik the Outgolfer's Python 2 solution. I saved a few bytes on his code by recasting my equations to work with [2..40] instead of [1..20].
The code for generating rank orders takes up more than 2/3 of the bytes of the whole solution. If anyone has a more compact way of generating ranks, this solution could be shortened further. Because of the accuracy penalty (around 2.6), the score would improve quite a bit.
Generating the Equation
I used statistical methods to search for simple equations to estimate the size of each body based on its rank. In part following up on the insights in @Level River St's Ruby solution and generalizing, I settled on equations of the form:
Radius = A/(Rank)**B
Working in R, I used linear models on the log of the radii to develop initial estimates, and then used non-linear optimization, seeding the optimization with the results of the linear models, to search for solutions that minimized the penalty function specified in the problem.
The estimated value of A in the above equation is seven digits, so I searched for a simple expression to save a couple of bytes. I looked for expressions of the form
x**y
for two digit x and 1 digit y (for a total of five bytes, saving two bytes, or about five points, given the penalty) that was not too different from the optimum value of A and did not inflate the penalty much, and ended up with the (otherwise inexplicable):
39**4
Python 2, 89 bytes, Score = 234
lambda(p):39**4/'zzuSJJaSrUNNrEnVsMeGtTMMoCoInMuErTuPsEaHTT'.find(p[7%len(p)]+p[0])**2.18
Try it online!
Most answers posted appear to have used a "encode/decode" strategy. I wondered how well I could do by estimating the diameter of celestial bodies using a simple equation. It's been a fun exercise, but the moderate byte savings are more than made up for by the accuracy penalty.
The core of this solution is the estimating equation:
Radius = 39**4/x**2.18
where x is twice the rank order of the radius of the body.
I generate the value of x based on the input string using a modification of @Erik the Outgolfer's Python 2 solution. I saved a few bytes on his code by recasting my equations to work with [2..40] instead of [1..20].
The code for generating rank orders takes up more than 2/3 of the bytes of the whole solution. If anyone has a more compact way of generating ranks, this solution could be shortened further. Because of the accuracy penalty (around 2.6), the score would improve quite a bit.
Generating the Equation
I used statistical methods to search for simple equations to estimate the size of each body based on its rank. In part following up on the insights in @Level River St's Ruby solution and generalizing, I settled on equations of the form:
Radius = A/(Rank)**B
Working in R, I used linear models on the log of the radii to develop initial estimates, and then used non-linear optimization, seeding the optimization with the results of the linear models, to search for solutions that minimized the penalty function specified in the problem.
The estimated value of A in the above equation is seven digits, so I searched for a simple expression to save a couple of bytes. I looked for expressions of the form
x**y
for two digit x and 1 digit y (for a total of five bytes, saving two bytes, or about five points, given the penalty) that was not too different from the optimum value of A and did not inflate the penalty much, and ended up with the (otherwise inexplicable):
39**4
answered Dec 12 at 5:21
CCB60
1395
1395
The scoring algorithm really seems to hurt this method-- I'd guess that it would do better under L2 or L1 norm of error. Though you're wasting bytes storing the names anyway.
– lirtosiast
Dec 12 at 6:15
@lirtosiast Agree to both points. Interestingly, a least squares fit (L2 norm) is pretty good under this scoring algorithm too. It has only about 5% worse penalty than the best equation I found. On storing the names : I could not figure out a more compact way to generate an ascending sequence of numbers from text input. The modulo arithmetic approaches taken in other answers randomize the order.
– CCB60
Dec 12 at 14:13
add a comment |
The scoring algorithm really seems to hurt this method-- I'd guess that it would do better under L2 or L1 norm of error. Though you're wasting bytes storing the names anyway.
– lirtosiast
Dec 12 at 6:15
@lirtosiast Agree to both points. Interestingly, a least squares fit (L2 norm) is pretty good under this scoring algorithm too. It has only about 5% worse penalty than the best equation I found. On storing the names : I could not figure out a more compact way to generate an ascending sequence of numbers from text input. The modulo arithmetic approaches taken in other answers randomize the order.
– CCB60
Dec 12 at 14:13
The scoring algorithm really seems to hurt this method-- I'd guess that it would do better under L2 or L1 norm of error. Though you're wasting bytes storing the names anyway.
– lirtosiast
Dec 12 at 6:15
The scoring algorithm really seems to hurt this method-- I'd guess that it would do better under L2 or L1 norm of error. Though you're wasting bytes storing the names anyway.
– lirtosiast
Dec 12 at 6:15
@lirtosiast Agree to both points. Interestingly, a least squares fit (L2 norm) is pretty good under this scoring algorithm too. It has only about 5% worse penalty than the best equation I found. On storing the names : I could not figure out a more compact way to generate an ascending sequence of numbers from text input. The modulo arithmetic approaches taken in other answers randomize the order.
– CCB60
Dec 12 at 14:13
@lirtosiast Agree to both points. Interestingly, a least squares fit (L2 norm) is pretty good under this scoring algorithm too. It has only about 5% worse penalty than the best equation I found. On storing the names : I could not figure out a more compact way to generate an ascending sequence of numbers from text input. The modulo arithmetic approaches taken in other answers randomize the order.
– CCB60
Dec 12 at 14:13
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
2
Sandbox (now deleted). Thanks to all who provided feedback, and especially xnor for helping fix the scoring formula.
– Arnauld
Dec 5 at 14:07
1
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
Dec 5 at 15:03
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
Dec 5 at 15:10
2
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
Dec 6 at 10:17
2
@maxb You'll have to beat Jelly's score of 37, not 05AB1E's score of 60 ;p
– Kevin Cruijssen
Dec 6 at 10:55