lambda S:`6793**164`[len(S)]
Try it online!
Unfortunately still one byte longer than the best Python 2 answer thus far; though not using the enklact
-approach.
Now one byte shorter than i cri everytim's answer!
How does it work?
After a lot of brute force, I found an expression that results in a number which has just the right digits.
I noticed that looking at only one specific digit of the given string's lengths required 3 bytes (%10
). So I wrote another Python program (Pastebin link) to further search for numbers who directly map the input strings' lengths to the day of the week.
The magic number looks like this: 6793**164 = 28714733692312345620167113260575862840674216760386883406587492336415023761043044176257567032312859371641211117824224067391750766520256112063756278010050204239810862527958109285342869876264808102743173594017101607983288521836082497514383184553444755034407847810524083812459571382103831904835921560285915349760536969265992879312869538914200854305957428078269094250817029486005437991820466986793657301214564264748923199288698278615871481529585816783654841131577178922192383679718074693535597651237893794976519274268917335387876260270630339777501802739852278932279775510324916969726203688466311848240746465178859847331248655567344801
(a number with an impressive 629 decimal digits)
And as you can see, the number provides the necessary mapping from [28, 20, 13, 11, 4, 16, 17] to [0, 1, 2, 3, 4, 5, 6] (Python strings are 0-indexed):
2871 4 733692 3 1 2 34 5 6 20 1 6711326 0 5758628406742167603868834...
[4]^ [11]^ [13]^ [16]^ ^[17] ^[20] ^[28]
My program also found other expressions which yield numbers with the required property, though they take more bytes to represent (29 instead of 28): 19439**540
, 34052**726
, 39311**604
, 44873**182
, 67930**164
and 78579**469
. (Those are all the expressions found by the linked program; its execution took several hours.)
Alternative function that requires 28 bytes: lambda S:`7954<<850`[len(S)]
Alternative function that requires 29 bytes: lambda S:`9699<<2291`[len(S)]
Alternative function that requires 30 bytes: lambda S:`853<<4390`[len(S)+9]
Alternative function that requires 31 bytes: lambda S:`1052<<3330`[len(S)+8]
How does it work? How did I generate that number? (30 byte answer)
The 30 byte answer was lambda S:`3879**41`[len(S)%10]
.
Looking at the input string's lengths [28, 20, 13, 11, 4, 16, 17]
, I noticed that all last digits in base ten differ, resulting in the list [8, 0, 3, 1, 4, 6, 7]
. So I only needed a mapping from that list to the list of all seven days of the week, [0, 1, 2, 3, 4, 5, 6]
.
My first approach simply used a string to perform the mapping: lambda S:"13*24*560"[len(S)%10]
, though the string required eleven bytes ("13*24*560"
).
So I wrote a Python program (Pastebin link) to test for arithmetic expressions which result in an integer with matching digits, hoping to further golf the program. What I came up with thus far is `3879**41`
(only ten bytes, the only and thereby smallest expression my program finds).
Of course, there are many different possible expressions one could try; I just got lucky that there was one in the form a**b
with a reasonably small result that fit my need.
Just for anyone curious, 3879**41 = 1372495608710279938309112732193682350992788476725725221643007306215781514348937145528919415861895033279220952836384201346579163035594383625990271079 = 1.372... * 10**147
.
Another valid function I found whilst searching for alternative expressions that unfortunately requires 32 bytes: lambda S:`7**416`[len(S)%10+290]
8Don't really see how this Kolmogorov complexity. The text is the input...numbers are the output. – geokavel – 2017-09-05T15:45:15.007
Fixed inputs and outputs are considered [tag:kolmogorov-complexity] by some people. – Erik the Outgolfer – 2017-09-05T15:45:45.247
5Also does Sunday say "Meatball Marinara" or "Meatball Marina Ra"? – Erik the Outgolfer – 2017-09-05T16:09:06.447
17
I'm pretty sure it's supposed to be Marinara but the keming in the image is pretty awful...
– totallyhuman – 2017-09-05T16:14:03.0701@i cri everytim do you mean kerning? – Restioson – 2017-09-05T18:05:55.380
2@Restioson Yes, that was an intentional typo. :P – totallyhuman – 2017-09-05T18:07:24.317
6If it's useful to anyone: the number of
a
's plus the number ofe
's in each input is [5,4,3,2,1,3,6] respectively. – geokavel – 2017-09-05T18:14:55.69022When you use
sudo
. – jpmc26 – 2017-09-05T19:10:32.9574
@jpmc26 That doesn't work, and in fact, might be dangerous.
– JiK – 2017-09-07T19:36:43.0473How am I seeing this question? I have ad-blocker turned on. – None – 2017-09-08T11:56:04.417