Print this maximally long URL

29

3

Task

This one is simple. We want to compress a URL, but don't trust URL shorteners.

Write a program that prints to stdout (or a 0-argument function that returns) the following, working URL:

http://a.b.c.d.e.f.g.h.i.j.k.l.m.n.oo.pp.qqq.rrrr.ssssss.tttttttt.uuuuuuuuuuu.vvvvvvvvvvvvvvv.wwwwwwwwwwwwwwwwwwwwww.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.me

Code golf, standard rules.

You may output uppercase or lowercase.

Leading or trailing whitespace is ok.

Context

Explanation taken from the website:

The domain is created to reach the maximum number of allowed characters (255 (really 253)) with an exponential curve in the length of the letters as you proceed through the alphabet. The formula used is "1 + 62 * (10/7)^(x-26)". To help illustrate this curve, reference the distribution on this spreadsheet. It's colorful because I like colors and wanted to do a progressive "rainbow" animation in CSS3.

Jonah

Posted 2020-02-05T23:17:02.297

Reputation: 8 729

Answers

6

APL (Dyalog), 41 38 bytes

-3 bytes thanks to Bubbler

2⌽'mehttp://',∊'.',¨⍨⎕A⍴¨⍨⌊1+62×.7*⍒⎕A

Try it online!

Outputs the URL with the letters capitalised. Uses the 0 indexed formula \$ \lfloor 1 + 62 \times 0.7^{25-x} \rfloor \$, since \$ (\frac{10}{7})^{x-25} = ((\frac{7}{10})^{-1})^{x-25} = (\frac{7}{10})^{25-x}\$

Explanation:

2⌽                         ⍝ Rotate by two places (moving the 'me' to the end)
  'mehttp://'              ⍝ The start string
             ,             ⍝ Followed by
              ∊               ⍝ The flattened string of
               '.'            ⍝ A period
                  ,⍨¨         ⍝ Appended to the end of each of
                     ⎕A            ⍝ The uppercase alphabet
                       ⍴¨⍨         ⍝ Where each letter is repeated by
                          ⌊               ⍝ The floor of
                           1+             ⍝ 1 plus
                             62×          ⍝ 62 times
                                .7*       ⍝ 0.7 to the power of
                                   ⍒⎕A  ⍝ The range 26 to 1

Jo King

Posted 2020-02-05T23:17:02.297

Reputation: 38 234

are the final two dots in ,⍨¨ the equivalent of J's rank 0 adverb "0? Does APL have the ability to specify other specific ranks? – Jonah – 2020-02-06T01:52:23.550

1@Jonah Yes, ¨ is the each function, which applies an operator to each element of the vector. I don't think you can specify rank with that specific function, though I'm not an expert with APL. Try asking Adam in chat – Jo King – 2020-02-06T02:01:48.713

3@Jonah is like J's stdlib's each, or f&.:>"0. The "0 part is ⍤0 in APL. Unfortunately, we don't have J's (new) L: (though I'm arguing for adding it as ). – Adám – 2020-02-06T06:16:58.183

6

05AB1E, 25 24 23 21 bytes

žXAS.7Ƶ-t∞-m>×….me¬ýJ

-1 byte thanks to @Neil's analysis that *(10/7)** is the same as /.7**.
-3 bytes thanks to @Grimmy using a different formula and ingenious use of ý!

Try it online.

Explanation:

The formula used to get the correct amount of characters of the alphabet, where \$n\$ is the 1-based index of the alphabetic letter:
\$a(n) = \left\lfloor0.7^{(\sqrt{208}-n)}+1\right\rfloor\$

žX                     # Push builtin "http://"
      Ƶ-               # Push compressed 208
        t              # Take the square-root of that: 14.422...
         ∞             # Push an infinite list of positive integers: [1,2,3,...]
          -            # Subtract each from the 14.422...: [13.442...,12.442...,...]
    .7     m           # Take 0.7 to the power of each of these: [0.008...,0.011...,...]
            >          # Increase each by 1: [1.008...,1.011...,...]
  AS                   # Push the lowercase alphabet as list of characters,
             ×         # and repeat each the calculated values amount of times as string
                       # (which implicitly truncates the floats to integers, and ignores
                       #  the floats beyond the length of the alphabet)
              ….me     # Push ".me"
                  ¬    # Push its head (the "."), without popping the ".me" itself
                   ý   # Join with delimiter. Normally it will use the top value as
                       # delimiter and joins the top-1'th list. In this case however, the
                       # top-1'th item is a string, so instead it will join the entire stack
                       # together. BUT, because the stack contains a list, it will instead
                       # only join all lists on the stacks by the "." delimiter
                    J  # And finally join the three strings on the stack together
                       # (after which this result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶ- is 208.

Kevin Cruijssen

Posted 2020-02-05T23:17:02.297

Reputation: 67 575

05AB1E even has a builtin for "http://". I'm impressed – Embodiment of Ignorance – 2020-02-07T02:40:43.203

@EmbodimentofIgnorance Yep. žX is "http://"; žY is "https://" and žZ is "http://www." :) – Kevin Cruijssen – 2020-02-07T07:20:49.407

22 – Grimmy – 2020-02-07T15:04:21.940

121 (: Also, here's a 20 that almost works (1 extra v, 1 missing z). – Grimmy – 2020-02-07T17:35:30.270

@Grimmy Very nice! Both the new formula with sqrt(208) and how you've used the ý to join the list somewhere on the stack is ingenious! :D – Kevin Cruijssen – 2020-02-07T18:08:10.623

5

Python 3, 86 \$\cdots\$ 81 77 bytes

Saved 3 bytes thanks to mypetlion!!!
Saved 4 bytes thanks to Shieru Asakoto!!!

print(f"http://{'.'.join(chr(i+97)*int(1+.7**-i/120)for i in range(26))}.me")

Try it online!

Uses Shieru Asakoto's 0-based formula.

Noodle9

Posted 2020-02-05T23:17:02.297

Reputation: 2 776

81 bytes: print(f"http://{'.'.join(chr(i+122)*int(1+62*1.43**i)for i in range(-25,1))}.me") – mypetlion – 2020-02-05T23:47:40.160

1@mypetlion Clever reshuffle of braced expressions - thanks! :-) – Noodle9 – 2020-02-05T23:52:52.393

77 bytes when using an alternative formula. – Shieru Asakoto – 2020-02-06T01:00:18.177

1@ShieruAsakoto Was just adding that - thanks! :-) – Noodle9 – 2020-02-06T01:01:32.137

4

Perl 5, 61 57 55 bytes

-4 bytes thanks to @Neil

say"http://",(map{$_ x(1+62/.7**(++$p-26))."."}a..z),me

Try it online!

Xcali

Posted 2020-02-05T23:17:02.297

Reputation: 7 671

2I think *(10/7)** is the same as /(7/10)** or /.7**. – Neil – 2020-02-06T01:10:52.280

4

JavaScript (Node.js), 77 bytes

Based on @ShieruAsakoto's formula. Builds the URL recursively.

f=n=>n>25?".me":(n?".".padEnd(2+.7**-n/120,Buffer([97+n])):"http://a")+f(-~n)

Try it online!

Arnauld

Posted 2020-02-05T23:17:02.297

Reputation: 111 334

4

Java (JDK), 108 bytes

v->{var s="HTTP://";for(char c=64,t;++c<91;s+=(""+c).repeat(t/=Math.pow(.7,c-90))+c+".")t=62;return s+"ME";}

Try it online!

Credits

  • -4 bytes thanks to Kevin Cruijssen

Olivier Grégoire

Posted 2020-02-05T23:17:02.297

Reputation: 10 647

Very likely golfable using math. – Olivier Grégoire – 2020-02-06T10:06:14.473

1

-3 byte using 62/Math.pow(.7,c-122) (credit goes to @Neil).

– Kevin Cruijssen – 2020-02-06T10:22:47.897

1And an additional -1 with for(char c=96,t;++c<123;s+=(""+c).repeat(t/=Math.pow(.7,c-122))+c+".")t=62; – Kevin Cruijssen – 2020-02-06T10:28:12.267

3

Charcoal, 27 bytes

http://⭆β⁺×ι⊕×⁶²X·⁷⁻²⁵κ.¦me

Try it online! Link is to verbose version of code. Explanation:

http://                     Implicitly print literal string `http://`
        β                   Lowercase alphabet
       ⭆                    Map over letters and join
                      κ     Current index
                   ⁻²⁵      Subtract from 25
                X·⁷         Raise 0.7 to that power
             ×⁶²            Multiply by 62
            ⊕               Increment
          ×ι                Repeat letter that many times
         ⁺             .    Concatenate literal string `.`
                        ¦   Implicitly print
                         me Implicitly print literal string `me`

Neil

Posted 2020-02-05T23:17:02.297

Reputation: 95 035

3

Jelly, 49 48 46 31 bytes (send help)

A niladic link printing the URL

26RU.7*×89ĊØa×⁾meṭj”.“http://”;

-2 bytes thanks to Kevin

-15 bytes thanks to Nick!

I never wrote anything this complex in Jelly and the tacicity isn't obvious to me yet... So this is very golfable (see 49 byte link). I would appreciate feedback and golfing tips in small chunks so that I can digest it!

You can try this online.

RGS

Posted 2020-02-05T23:17:02.297

Reputation: 5 047

Your https:// can be http:// ;) – Kevin Cruijssen – 2020-02-06T12:31:04.700

@KevinCruijssen gosh, I missed this entirely :D ty – RGS – 2020-02-06T13:22:51.187

1Np. Unfortunately I can't really help you with the rest, since I don't know a lot about Jelly. Only thing that comes to mind is removing the trailing , since it's closed implicitly to save a byte. But since my 05AB1E answer is 23 bytes, I'm sure <30 should be easily possible for Jelly as well. ;) – Kevin Cruijssen – 2020-02-06T13:25:49.060

@KevinCruijssen I don't doubt that. It's just that Jelly is still so weird for me :p thanks for your input – RGS – 2020-02-06T13:35:25.573

1

Here’s a 31 byte answer for comparison. In general, it’s helpful to try to have a single link that proceeds from left to right whenever possible. Other useful hints include use of j (join) for your last line (though I’ve changed it to add the me earlier), use of the Ø nilads, reversing the order of the list rather than subtracting from 26. Happy for you to use my answer (and improve it if possible). Note it was derived from @KevinCruijsen’s answer. It’s longer because of the “http://”

– Nick Kennedy – 2020-02-06T19:56:28.913

1@NickKennedy this was an unbelievable byte discount. I'll have to digest your submission calmly. Thanks a lot! – RGS – 2020-02-06T22:20:10.213

2

Wolfram Language (Mathematica), 71 bytes

"http://"<>Array[Table[Alphabet[][[#]],1+1.43^(#-26)62]<>"."&,26]<>"me"

Try it online!

JungHwan Min

Posted 2020-02-05T23:17:02.297

Reputation: 13 290

2

C (gcc), 99 bytes

n;f(i){for(i=printf("http://");i<33;)for(n=62/pow(.7,i++-32)+2;n--;)putchar(n?89+i:46);puts("me");}

-3 or so bytes thanks to Noodle9!

-8 bytes thanks to gastropner!

Try it online!

S.S. Anne

Posted 2020-02-05T23:17:02.297

Reputation: 1 161

1

Dump one of the printf()s for 101 bytes

– gastropner – 2020-02-06T02:03:52.067

@gastropner Thanks. Added a size decrease from another answer too. – S.S. Anne – 2020-02-06T17:50:45.637

2

JavaScript (Node.js), 93 bytes

_=>`http://${[...Array(26)].map((x,i)=>Buffer(Array(1+.7**-i/120|0).fill(97+i))).join`.`}.me`

Try it online!

When turning the formula into 0-indexed, the formula becomes \$1+62\times(\frac{10}{7})^{x-25}=1+0.0083146\times0.7^{-x}\$, and then 0.0083146 is approximated by 1/120.

Shieru Asakoto

Posted 2020-02-05T23:17:02.297

Reputation: 4 445

1Same length variant: _=>`http://${"abcdefghijklmnopqrstuvwxuz".replace(/./g,(x,i)=>x.repeat(1+.7**-i/120)+`.`)}me` – Neil – 2020-02-06T01:08:06.867

177 bytes – Arnauld – 2020-02-06T05:57:08.090

1@Arnauld I suggest you post it as a separate answer because the approach is quite different on this. I've rolled back your golf to let you post it. – Shieru Asakoto – 2020-02-06T05:59:35.000

2

Japt, 29 bytes

;`http://{C®p.7**T´/#xÄ +'.}´

Saved 2 bytes thanks to @Shaggy

Test it

Embodiment of Ignorance

Posted 2020-02-05T23:17:02.297

Reputation: 7 014

29 bytes? – Shaggy – 2020-02-06T08:19:37.320

@Shaggy Thanks, I forgot that ** exists – Embodiment of Ignorance – 2020-02-07T02:34:23.233

2

R, 124 115 63 bytes

This is way better than my original approach. Thanks to @Giuseppe and @Grimmy

cat("http://");cat(strrep(letters,1+62*.7^(25:0)),"me",sep=".")

Try it online!

John

Posted 2020-02-05T23:17:02.297

Reputation: 171

269 bytes; feel free to come to the R golfing chat if you wanna discuss ideas there :-) – Giuseppe – 2020-02-08T00:46:29.047

2

@Giuseppe 65 based on your 69.

– Grimmy – 2020-02-08T01:20:21.140

@Giuseppe and Grimmy, thanks! Very impressive trimming. – John – 2020-02-08T13:10:51.750

2

Haskell, 86 bytes

g(c,x)=replicate(floor$1+62*1.43**x)c++"."
f="http://"++(zip['a'..][-25..0]>>=g)++"me"

Try it online!

user28667

Posted 2020-02-05T23:17:02.297

Reputation: 579

1

C++ (gcc), 126 123 bytes

-3 bytes thanks to S.S. Anne

Some acrobatics needed to avoid having to include cmath.

#import<map>
using s=std::string;s f(){s r="http://";for(float i=26,p=7456;i--;p*=.7)r+=s(1+62/p,122-i)+'.';return r+"me";}

Try it online!

gastropner

Posted 2020-02-05T23:17:02.297

Reputation: 3 264

You could use bits/stdc++.h and use cmath's functions. – S.S. Anne – 2020-02-06T18:00:49.470

@S.S.Anne I might misunderstand you, but that would take even more bytes to include than cmath. – gastropner – 2020-02-06T20:45:51.850

But not string and cmath combined. Instead of #import<string> #import<cmath> (in this hypothetical solution) you could do #import<bits/stdc++.h>. – S.S. Anne – 2020-02-06T20:55:35.967

@S.S.Anne Oh, I see what you mean! Had no idea about that one. Sadly it came out longer, doing that. – gastropner – 2020-02-06T21:08:36.493

1Well, then string can be replaced with map for -3 bytes. – S.S. Anne – 2020-02-06T21:11:28.660

ahem 123 bytes – S.S. Anne – 2020-02-07T18:24:40.600

@S.S.Anne Ah, nice one! Thought you were talking about the data type so had no idea where it was going :-P – gastropner – 2020-02-07T22:00:44.640

1

Keg, 46 40 bytes

`3);://`0&(‡26   |⑻a+ⁿ⅍7
/⑻±Ëx/ℤ1+⑹*\.)`me

Try it online!

A port of the Python 3 answer by Noodle9.

-6 bytes due to using string compression and some other things

Lyxal

Posted 2020-02-05T23:17:02.297

Reputation: 5 253

1

PHP, 94 bytes

for($c='a',$s='http://',$i=-26;$i++;$c++,$s.='.')for($l=62/.7**$i;$l-->=0;$s.=$c);echo$s.'me';

Try it online!

Probably still golfable, uses the formula from the question and PHP's char incrementing

EDIT: saved 3 bytes with code reorganization

EDIT2: another byte less starting from -26 and removing ($i-26)

Kaddath

Posted 2020-02-05T23:17:02.297

Reputation: 449

1

Ruby, 64 bytes

Conveniently, when multiplying a string with a non-whole positive number, Ruby truncates the number to determine how many times to repeat the string.

puts"http://#{(?a..?z).map{|c|c*(1+62/0.7**(c.ord-122))}*?.}.me"

Try it online!

Value Ink

Posted 2020-02-05T23:17:02.297

Reputation: 10 608

1

MATLAB 92 bytes

b="";for i=1:26;b=b+repelem(char(96+i),floor(1+62*(10/7).^(i-26)))+".";end;"http://"+b+"me"

Poelie

Posted 2020-02-05T23:17:02.297

Reputation: 131