76
\$\begingroup\$

This is the PPCG Prime

624 digits long

777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777111111111111111111111111111111111111111111111111111111111111111111111111111111188888888118888888811188888811188888811188111118818811111881881111881881111881188111118818811111881881111111881111111188888888118888888811881111111881118888188111111118811111111881111111881111881188111111118811111111881111881881111881188111111118811111111188888811188888811111111111111111111111111111111111111111111111111111111111111111111111111111111333333333333333333333333333333333333333

If we split every 39 digits we get
777777777777777777777777777777777777777
777777777777777777777777777777777777777
777777777777777777777777777777777777777
777777777777777777777777777777777777777
111111111111111111111111111111111111111
111111111111111111111111111111111111111
188888888118888888811188888811188888811
188111118818811111881881111881881111881
188111118818811111881881111111881111111
188888888118888888811881111111881118888
188111111118811111111881111111881111881
188111111118811111111881111881881111881
188111111118811111111188888811188888811
111111111111111111111111111111111111111
111111111111111111111111111111111111111
333333333333333333333333333333333333333

Your task is to output the PPCG-Prime

This is . The shortest code in bytes wins.

If you input the PPCG-Prime in the Mathematica function below, you get this result

ArrayPlot@Partition[IntegerDigits@#,39]&   

enter image description here

\$\endgroup\$
8
  • 44
    \$\begingroup\$ How on earth did you find this? \$\endgroup\$ – Stewie Griffin Oct 23 '17 at 6:38
  • 5
    \$\begingroup\$ @StewieGriffin The average probability for a number n to be prime is proportional to 1/log(n), which is not very small, anyway. Just check a lot of numbers until it's prime. \$\endgroup\$ – user202729 Oct 23 '17 at 6:40
  • 2
    \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ – Dennis Oct 23 '17 at 12:51
  • 1
    \$\begingroup\$ @user202729 log(n) is about 1436.6 in this case. \$\endgroup\$ – Jeppe Stig Nielsen Oct 24 '17 at 21:25
  • 4
    \$\begingroup\$ @Fabian I don't think this method would be efficient... For a Prime this big (624 digits), the number you are asking has 621 digits (and is even more difficult to golf), Unless this is the 10^621th prime!!! If you want to find your number, here is a simple approximation x/logx by Gauss \$\endgroup\$ – user72253 Oct 25 '17 at 13:31

29 Answers 29

24
\$\begingroup\$

Jelly, 55 54 52 47 46 bytes

“=÷¡v⁺ʋiṂYR¤"bİɲ}Ñ1Ṇ⁴ẠV⁹yȥGẇ’“¿mŻ“p’Dx39jBo88V

There are more convoluted approaches in the revision history, but this simple one beats them all.

Try it online!

How it works

“=÷¡v⁺ʋiṂYR¤"bİɲ}Ñ1Ṇ⁴ẠV⁹yȥGẇ’

This is a numeric literal, encoded in bijective base 250, where the digits are taken from Jelly's code page. The chain's (left) argument and the return value are set to the encoded integer,
n := 0x21871c77d7d7af6fafafeff0c37f72ff7fbfbdbfdfef5edfeff8e3.

“¿mŻ“p’

A similar literal to the above one, but the second separates two encoded integers. The return value is replaced with the encoded array, [777711, 113].

Dx39

D converts the return value to decimal ([[7, 7, 7, 7, 1, 1], [1, 1, 3]]), then x39 repeats each individual integer/digit in the result 39 times. This yields a pair of arrays, which contains the digits before and after the 7-character high text, respectively. Let's call this array A.

jB

First, B converts the (left) argument n to binary. This yields the digits that form the 7-character high text, where each 88 has been replaced by 0.

Then, j joins the array A, using the binary array as separator.

o88

This performs logical OR with 88, replacing each 0 with 88.

V

We have the correct digits now, but in an array of 7's, 1's, 88's, and 3's. V implicitly turns this array into a string and then evals it, yielding a single integer.

\$\endgroup\$
0
6
\$\begingroup\$

Bubblegum, 51 bytes

00000000: 331f c4c0 90ba c002 0a90 5986 d818 50d5  3.........Y...P.
00000010: 282c 3406 6e65 5036 1e4b 9195 8109 649d  (,4.neP6.K....d.
00000020: 5858 1896 4279 68b2 f895 61fa 94ca c098  XX..Byh...a.....
00000030: 3800 00                                  8..

Try it online!

\$\endgroup\$
6
\$\begingroup\$

SOGL V0.12, 52 51 bytes

≡=vā⁷H↕↕jΥ_Ν↑∆∫▲pΖo	‘θδžΟwd╬2n?q[‘²Κ7n⌡"α¼■╤ģ⅞¹‘¹H∑

ties bubblegum!
note that this answer contains a tab

Try it Here!

Tries to save bytes by reusing the same string for both of the Ps.

Explanation:

...‘...‘²Κ7n⌡"..‘¹H∑  compressed strings replaced with ellipses to shorten the width
...‘                  pushes "1111111188888188888888111118811111881111188111118881118818111811111111188888188888888111118811111881111188118118888818818881811118111" - CG
    ...‘              pushes "1111111888888888888881118118111811811181181118118111811811188881111881" - P
        ²             join with itself - double the P
         Κ            reverse add - prepend the PP to CG
          7n          split to line lengths of 7
            ⌡         for each
             "..‘       push "311ŗ117777" with ŗ replaced with the ToS - current item looping over
                 ¹    wrap the results tn an array
                  H   rotate it counter-clockwise
                   ∑  join to a single string

The numbers there are saved as from the original starting at the bottom left, going up, then 1 right & down, then up, ect.

A 52 byte plain compression version:

#⅓→9E■Ν►1&⅝θ⅞%øøμ←N═]y)u⅝↓$A○░(ZF16Φ⅓Mč▓d⅛Hι‼∑υnη▲Z‘

Try it Here!

\$\endgroup\$
7
  • \$\begingroup\$ I'm not sure if what you've posted is the correct code at all... \$\endgroup\$ – Erik the Outgolfer Oct 23 '17 at 11:32
  • 1
    \$\begingroup\$ how does ...‘ get those numbers? \$\endgroup\$ – Pureferret Oct 23 '17 at 12:33
  • 1
    \$\begingroup\$ @Pureferret String compression. \$\endgroup\$ – totallyhuman Oct 23 '17 at 12:44
  • \$\begingroup\$ @totallyhuman so how does it 'encode'/compress thoses strings into ...‘? \$\endgroup\$ – Pureferret Oct 23 '17 at 13:52
  • \$\begingroup\$ @dzaima I don't think that actually helps me understand, unfortunately. Entering the first part that encodes the CG into that tool doesn't give ...‘ anywhere in that tool. \$\endgroup\$ – Pureferret Oct 23 '17 at 13:59
5
\$\begingroup\$

CJam, ASCII, 61

Hs78f*~_@"'hfv;HH`>O4RU(_o^.U)9q&-1iadr`4tk"90b2b88fe|1$'339*

Try it online

Append ]s39/N* for nice wrapping.

Explanation:

Hs         generate "17" (H=17)
78f*       repeat each character 78 times, getting an array of 2 strings
~_         dump the 2 strings on the stack, and duplicate the '7's
@          move the '1's to the top of the stack (first 6 lines done so far)
"…"90b     convert that string from base 90 (treating characters as numbers)
2b         convert the resulting number to base 2,
            obtaining a bit map for the "PPCG" part, with 1 for "1" and 0 for "88"
88fe|      replace (boolean OR) all the zeros with 88
1$         copy the string of 78 '1's
'339*      repeat '3' 39 times
\$\endgroup\$
4
\$\begingroup\$

Mathematica, 107 bytes

Uncompress@"1:eJxTTMoP8ixgYmAwH8TAkLrAAgqQWYbYGFDVGCxkBh5lCDNwWIqqDCyGrAGDhWEpFmXY3IaiDItPqQqMiQMA+yaAoA=="


Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Correct me if I'm wrong, but is that a REPL-only solution? That doesn't seem to be a function (which I'm guessing you could fix with a single & on the end). \$\endgroup\$ – numbermaniac Oct 26 '17 at 8:20
  • \$\begingroup\$ this is not supposed to be a function. this code just outputs the PPCG prime, just like the OP asked \$\endgroup\$ – J42161217 Oct 26 '17 at 9:42
4
\$\begingroup\$

C, 519 427 414 396 377 bytes

Thanks to Tas, Felix Palmen and Lynn.

#define p(n,l)for(i=40*l;i;)putchar(--i%40?n+48:10);
f(i){p(7,4)p(1,2)puts("188888888118888888811188888811188888811\n188111118818811111881881111881881111881\n188111118818811111881881111111881111111\n188888888118888888811881111111881118888\n188111111118811111111881111111881111881\n188111111118811111111881111881881111881\n188111111118811111111188888811188888811");p(1,2)p(3,1)}

For your interest, here is a longer, easier-to-read version:

#define p(n,l) for(i=40*l;i;) putchar(--i%40?n+48:10);
f(i) {
    p(7,4)
    p(1,2)
    puts("188888888118888888811188888811188888811\n\
       188111118818811111881881111881881111881\n\
       188111118818811111881881111111881111111\n\
       188888888118888888811881111111881118888\n\
       188111111118811111111881111111881111881\n\
       188111111118811111111881111881881111881\n\
       188111111118811111111188888811188888811");
    p(1,2)
    p(3,1)
}
\$\endgroup\$
13
  • 1
    \$\begingroup\$ You can get much lower (~450ish) by simply printing the 1s and 8s as they are, and having a define for the 7, 3 and 1 \$\endgroup\$ – Tas Oct 24 '17 at 5:34
  • \$\begingroup\$ @Keyu Gan: I am compiling with a current version of GCC (7.2.0-debian11), which allows this for a couple of years. I'm not quite sure if the syntax is maybe in one of the newer C standards. \$\endgroup\$ – caylee Oct 24 '17 at 6:25
  • 2
    \$\begingroup\$ @Keyu Gan: It is allowed in C99 and C11. \$\endgroup\$ – caylee Oct 24 '17 at 6:30
  • 1
    \$\begingroup\$ 414 bytes \$\endgroup\$ – Felix Palmen Oct 24 '17 at 7:25
  • \$\begingroup\$ This version is very tricky. At least I understand it; thanks. \$\endgroup\$ – caylee Oct 24 '17 at 10:40
4
\$\begingroup\$

Java (OpenJDK 8), 165 bytes

n->{for(int i=0;++i<566;)System.out.print(i<157?7:i>526?3:i<236|i>446||new java.math.BigInteger("vnku5g6l0zenpa1kydel5rxw162k4fk4xapa154o",36).testBit(446-i)?1:88);}

Try it online!

Credits

  • -10 bytes thanks to aditsu!
\$\endgroup\$
2
  • \$\begingroup\$ 165: n->{for(int i=0;++i<566;)System.out.print(i<157?7:i>526?3:i<236|i>446||new java.math.BigInteger("vnku5g6l0zenpa1kydel5rxw162k4fk4xapa154o",36).testBit(446-i)?1:88);} \$\endgroup\$ – aditsu quit because SE is EVIL Oct 25 '17 at 17:20
  • \$\begingroup\$ Nice catch, the double 88, thanks! \$\endgroup\$ – Olivier Grégoire Oct 25 '17 at 17:56
2
\$\begingroup\$

Retina, 129 bytes


h155b78i7b1i7b2i5b2i5b2!4!!4!""1!4!!4!!6#i7b1i7b1!6!2i3b##!6"1##""1#!8i5b2i5b79d38
#
!7
"
!3!
!
i1b
\d+
$*
+`(\D)1
$1$1
1

T`l`d

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Batch, 364 335 333 bytes

@set a=888888&set b=1111111111111&set e=1881111&set d=1%e%&set f=333333333&for /L %%x in (1,1,156) do @cd|set/p=7
@echo %b%%b%%b%%b%%b%%b%1%a%8811%a%88111%a%111%a%1%d%188%e%188%e%88%e%88%d%188%e%188%e%1%d%1111%a%8811%a%88%d%111881118888%e%11%d%11%d%1%d%88%d%11%d%11%d%88%e%88%d%11%d%11111%a%111%a%%b%%b%%b%%b%%b%%b%11%f%%f%%f%%f%333
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Save two bytes by changing echo| to cd| \$\endgroup\$ – stevefestl Oct 23 '17 at 13:05
  • \$\begingroup\$ Thanks, I knew there was something shorter, but couldn't remember \$\endgroup\$ – schnaader Oct 23 '17 at 14:06
  • \$\begingroup\$ Also, (1,1,156) do can be shortened to (1,1,156)do \$\endgroup\$ – stevefestl Oct 23 '17 at 23:07
2
\$\begingroup\$

Javascript (ES6), 187 181 bytes

-6 bytes thanks to @JustinMariner

r=s=>s[0].repeat(39),a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`
z=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk".replace(/./g,eval)

Super simple approach; it could probably be golfed some more.

Explanation

r=s=>s[0].repeat(39),                               // helper function to repeat character
a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",// Set the variables (a-k) to different
e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`               // parts of the prime       

_=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk" // Replace all letters in the string
    .replace(/./g,eval)                             // with the value of the variable

Example code snippet (with some helper code to add line breaks in the output)

r=s=>s[0].repeat(39),a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`
z=_=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk".replace(/./g,eval)
o.innerText=z().replace(/.{39}/g,"$&\n")
<pre id=o>

\$\endgroup\$
1
  • \$\begingroup\$ You can save some bytes if you define a helper function r as r=s=>s[0].repeat(39) and then replace a, b, and k with r`7` etc. Try it online!. \$\endgroup\$ – Justin Mariner Oct 23 '17 at 21:26
2
\$\begingroup\$

C (gcc), 269 267 bytes

function, uses simple RLE.

x[]={39,79,80,156};k;f(i){for(char*c="d7b1882188316831683128512811285128112841281128412821285128112851281128712881882188212871283148112881288128712841282128812881284128112841282128812891683168c1a3";i=*c++;++c)for(i=i<97?i-48:x[i-97];i--;++k%39||puts(""))putchar(*c);}

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Suggest L"'OP\x9c" instead of x \$\endgroup\$ – ceilingcat Sep 6 '18 at 21:04
2
\$\begingroup\$

C (gcc), 224 bytes

f(i,j,c){for(i=0;c="wwdfFdfFDfFDfFDFDDFFDDFFDddDDFdDDddDDddDDDdDDDDffDffDFDDDFDfdDDDDFDDDdDDDdDDFdDDDDFDDDdDDFFDdDFDDDdDDDDdfDdfD"[i/2]>>i++%2*4&15;c-6?putchar(c-4?c+48:49):printf("88"))for(j=0;j++<c%2*38;)putchar(c+48);}

Try it online!

Contains some unprintables, the string literal is "ww\x11dfFdfFDfFDfFDFDDFFDDFFDddDDFdDDddDDddDDDdDDDDffDffDFDDDFDfdDDDDFDDDdDDDdDDFdDDDDFDDDdDDFFDdDFDDDdDDDDdfDdfD\x11\x03".

\$\endgroup\$
2
\$\begingroup\$

6502 machine code (C64), 142 122 bytes

00 C0 A9 27 85 FB A2 00 86 FC A2 04 CA 10 01 60 BC 70 C0 BD 74 C0 20 D2 FF C6
FB D0 0B 48 A9 27 85 FB A9 0D 20 D2 FF 68 88 D0 EB E0 02 D0 DD 48 A5 FC 4A A8
B9 4A C0 90 04 4A 4A 4A 4A 29 0F F0 08 E6 FC A8 68 49 09 D0 CD 68 D0 C0 28 38
36 36 52 12 52 12 42 12 42 22 52 12 52 12 72 82 28 28 72 32 14 82 82 72 42 22
82 82 42 12 42 22 82 92 36 06 27 50 4F 9C 33 31 31 37

Online demo

Usage: sys49152

  • -20 bytes with better implementation of same method and data tables for large blocks as well.

Explanation

This also uses the lengths of the 1 and 8 sequences in the middle part; as they're all shorter than 16, two of them are encoded per byte.

Commented disassembly listing:

         00 C0        .WORD $C000       ; load address
.C:c000  A9 27        LDA #$27          ; counter for newlines (39)
.C:c002  85 FB        STA $FB
.C:c004  A2 00        LDX #$00          ; index for run-length data
.C:c006  86 FC        STX $FC
.C:c008  A2 04        LDX #$04          ; index for "blocks" (counting down)
.C:c00a   .blockloop:
.C:c00a  CA           DEX
.C:c00b  10 01        BPL .continue     ; block index underflow -> done
.C:c00d  60           RTS
.C:c00e   .continue:
.C:c00e  BC 70 C0     LDY .lseqlens,X   ; load length of next block to Y
.C:c011  BD 74 C0     LDA .chars,X      ; load character of next block to A
.C:c014   .outloop:
.C:c014  20 D2 FF     JSR $FFD2         ; output character
.C:c017  C6 FB        DEC $FB           ; decrement newline counter
.C:c019  D0 0B        BNE .skipnl
.C:c01b  48           PHA               ; newline needed -> save accu
.C:c01c  A9 27        LDA #$27          ; restore newline counter
.C:c01e  85 FB        STA $FB
.C:c020  A9 0D        LDA #$0D          ; load newline character
.C:c022  20 D2 FF     JSR $FFD2         ; output character
.C:c025  68           PLA               ; restore accu
.C:c026   .skipnl:
.C:c026  88           DEY               ; decrement repeat counter
.C:c027  D0 EB        BNE .outloop      ; repeat until 0
.C:c029  E0 02        CPX #$02          ; check for block index of text part
.C:c02b  D0 DD        BNE .blockloop    ; not in text part -> repeat
.C:c02d   .textpart:
.C:c02d  48           PHA               ; save accu
.C:c02e  A5 FC        LDA $FC           ; load index for run-length data
.C:c030  4A           LSR A             ; and shift right
.C:c031  A8           TAY               ; -> to Y register
.C:c032  B9 4A C0     LDA .seqlens,Y    ; load run-length data
.C:c035  90 04        BCC .lownibble    ; carry clear from shift -> low nibble
.C:c037  4A           LSR A             ; shift high nibble into low nibble
.C:c038  4A           LSR A
.C:c039  4A           LSR A
.C:c03a  4A           LSR A
.C:c03b   .lownibble:
.C:c03b  29 0F        AND #$0F          ; mask low nibble
.C:c03d  F0 08        BEQ .textdone     ; run-length zero? then text block done
.C:c03f  E6 FC        INC $FC           ; increment index for run-length data
.C:c041  A8           TAY               ; run-length to y-register
.C:c042  68           PLA               ; restore accu
.C:c043  49 09        EOR #$09          ; toggle between '8' and '1'
.C:c045  D0 CD        BNE .outloop      ; and back to output loop
.C:c047   .textdone:
.C:c047  68           PLA               ; restore accu
.C:c048  D0 C0        BNE .blockloop    ; back to loop for next block
.C:c04a   .seqlens:
.C:c04a  28 38 36 36  .BYTE $28,$38,$36,$36
.C:c04e  52 12 52 12  .BYTE $52,$12,$52,$12
.C:c052  42 12 42 22  .BYTE $42,$12,$42,$22
.C:c056  52 12 52 12  .BYTE $52,$12,$52,$12
.C:c05a  72 82 28 28  .BYTE $52,$82,$28,$28
.C:c05e  72 32 14 82  .BYTE $72,$32,$14,$82
.C:c062  82 72 42 22  .BYTE $82,$72,$42,$22
.C:c066  82 82 42 12  .BYTE $82,$82,$42,$12
.C:c06a  42 22 82 92  .BYTE $42,$22,$82,$92
.C:c06e  36 06        .BYTE $36,$06
.C:c070   .lseqlens:
.C:c070  27 50 4F 9C  .BYTE $27,$50,$4F,$9C
.C:c074   .chars:
.C:c074  33 31 31 37  .BYTE "3117"
\$\endgroup\$
2
+50
\$\begingroup\$

R, 178 165 bytes

-10 bytes thanks to Dominic van Essen

`?`=c
w=8?2?8?2
x=5?2?1?2
y=2?4?2?2?2
z=4?2?1?y
cat(rep(7?0:76%%2*7+1?3,156?79?8?2?8?3?6?3?6?3?2?x?x?z?x?x?7?2?8?w?2?7?2?3?4?1?2?w?7?y?w?z?8?2?9?6?3?6?80?39),sep="")

Try it online!

A run-length-decoding solution with a few optimizations thanks to this tip.

\$\endgroup\$
3
  • \$\begingroup\$ Nice! Welcome to R! rep is shorter than rep.int for 174 bytes. \$\endgroup\$ – Dominic van Essen Sep 7 '20 at 6:03
  • 1
    \$\begingroup\$ And, if you can bear it, redefining the (otherwise unused) binary operator / as c can also save some bytes, at the expense of quite severe obfuscation... \$\endgroup\$ – Dominic van Essen Sep 7 '20 at 6:09
  • 1
    \$\begingroup\$ Oh, I can bear it. :D In fact, using ? is even better because of its lower precedence. I was experimenting with redefining an operator to condense all the a,b,a sequences (couldn't find a way that saved bytes--function is expensive), but I didn't notice that redefining c would be helpful too. \$\endgroup\$ – DLosc Sep 7 '20 at 16:11
2
\$\begingroup\$

x86-16 machine code, IBM PC DOS, 117 108 107 bytes

Binary:

00000000: be14 01b1 53ac d404 bb67 01d7 cd29 fecc  ....S....g...)..
00000010: 75fa e2f1 c3ff b7fd 4122 0922 0d1a 0d1a  u.......A"."....
00000020: 0d0a 150a 050a 150a 050a 110a 050a 110a  ................
00000030: 090a 150a 050a 150a 050a 1d0a 2122 0922  ............!"."
00000040: 090a 1d0a 0d12 050a 210a 210a 1d0a 110a  ........!.!.....
00000050: 090a 210a 210a 110a 050a 110a 090a 210a  ..!.!.........!.
00000060: 251a 0d1a fd45 9c33 3138 37              %....E.3187

Listing:

BE 011E         MOV  SI, OFFSET DAT     ; RLE table 
BB 0171         MOV  BX, OFFSET CHR     ; character table 
B1 53           MOV  CL, 83             ; data length 
            BYTE_LOOP: 
AC              LODSB                   ; AL = byte
D4 04           AAM  4                  ; Unpack AL = char index, AH = run length 
D7              XLAT                    ; AL = ASCII char 
            RLE_LOOP:
CD 29           INT  29H                ; write char to console 
FE CC           DEC  AH                 ; decrement length counter 
75 FA           JNZ  RLE_LOOP           ; loop until end of run 
E2 EC           LOOP BYTE_LOOP          ; loop until end of bytes
            DAT:
C3              RET                     ; return to DOS (and first byte of DAT)
                DB  0FFH,0B7H,0FDH,41H,22H,09H,22H,0DH,1AH,0DH
                DB  1AH,0DH,0AH,15H,0AH,05H,0AH,15H,0AH,05H,0AH,11H
                DB  0AH,05H,0AH,11H,0AH,09H,0AH,15H,0AH,05H,0AH,15H
                DB  0AH,05H,0AH,1DH,0AH,21H,22H,09H,22H,09H,0AH,1DH
                DB  0AH,0DH,12H,05H,0AH,21H,0AH,21H,0AH,1DH,0AH,11H
                DB  0AH,09H,0AH,21H,0AH,21H,0AH,11H,0AH,05H,0AH,11H
                DB  0AH,09H,0AH,21H,0AH,25H,1AH,0DH,1AH,0FDH,45H,9CH
            CHR: 
                DB  '3','8','1','7'

Uses a form of RLE to encode the lengths for each run of numbers. Since there's only four possible numbers, these are encoded using 2 bits of each byte and the remaining 6 bits for the length of the run. This compresses the 624 byte input down to 83. For example:

Run       Len    Num   Hex
888888 -> 000110 10  = 0x1A
777    -> 000011 00  = 0x0C
1111   -> 000100 01  = 0x11

A standalone PC DOS executable COM program. Output to console (in delightful MDA amber today):

enter image description here

Or formatted with line breaks:

enter image description here

-8 bytes thanks to @gastropner for the excellent idea to use AAM to unpack the byte instead of bit shifting!

-1 byte thanks to @gastropner adjusting data to start with a 0xC3 (RET opcode)!

\$\endgroup\$
4
  • \$\begingroup\$ You can shave off 8 bytes by replacing the bit fiddling and the XCHG AL, AH with a single AAM 04H and swapping the 8 and the 1 in CHR. \$\endgroup\$ – gastropner Sep 7 '20 at 3:08
  • \$\begingroup\$ @gastropner oh, that's gooood! I had never thought to use AAM to unpack a byte. Thanks! \$\endgroup\$ – 640KB Sep 7 '20 at 12:29
  • \$\begingroup\$ There is one more byte to be had, slightly more hard-earned: DB 7BH,0FFH,0FFH -> DB 0DBh,0DBh (and 9Fh to 9CH at the end), change CHR to DB '3','1','8','7', and move DAT before RET to have that last instruction double as data. \$\endgroup\$ – gastropner Sep 7 '20 at 19:25
  • \$\begingroup\$ @gastropner very clever - thanks! Updated! \$\endgroup\$ – 640KB Sep 8 '20 at 16:30
1
\$\begingroup\$

Jelly, 86 bytes

Lẋ@1,8żḣLẋ/€F
7ẋ156;1ẋ78¤©;“½Ẹ^o“2FẒ⁶ġbȥ“¡E⁷£cṿ“t¡ɗḋ“£F¢Xȥ“¡McṾbȥ“¬3Ṭo’DÇ€F¤;®;3rẋ39¤Ḍ

Try it online!

-12 bytes thanks to user202729

\$\endgroup\$
3
  • \$\begingroup\$ 88 bytes: TIO ( can separates a list of strings inside a string literal) \$\endgroup\$ – user202729 Oct 23 '17 at 6:37
  • \$\begingroup\$ What time is it in your country? Why are you awake right now? \$\endgroup\$ – user202729 Oct 23 '17 at 6:37
  • \$\begingroup\$ @user202729 Oh right, thanks. And I'm in UTC-4 I did a stupid and had to stay up rly late so I felt like doing a challenge before going to sleep since this got reopened. I can elaborate in chat if you'd like :P \$\endgroup\$ – HyperNeutrino Oct 23 '17 at 6:41
1
\$\begingroup\$

Python 2, 309 158 155 136 135 bytes

x='1'*78
s='7'*156+x
a=1
for c in str(int('109PDKEZ3U32K97KJQVELW8GKXCD42EGEYK715B6HPMPL0H8RU',36)):s+=`a`*int(c);a^=9
print s+x+'3'*39

Try it online!

Python 2, 137 bytes

s='7'*156
a=1
for c in'90'*8+str(int('PL6PU5TXIC24LCKIQY50C2LPAIC9TVZEVQGTMM63IHGBBUV1XSA6',36))+'09'*8:s+=`a`*int(c);a^=9
print s+'3'*39

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Jelly, 85 bytes

”7ẋ“ɓ’80“¡Ȯ⁶LÑɓĠ⁶-€Øġ°$¤ṛọḳƓƒṭ⁽@^ḥ⁷Ofạ<e½Ṇż;,RṘ¶ṀḊ+`⁸ⱮḃĿþṛ9.wƑ¡kḟUẎgLLµ’ḃĖŒṙị⁾1839”3ẋ

Try it online!

Based on Dennis's approach to the Trinity Hall challenge, minus the symmetry, plus the leading 7s and trailing 3s.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Dennis approached this challenge differently because it is a different one. I think you've been outgolfed! \$\endgroup\$ – user72253 Oct 23 '17 at 13:28
  • \$\begingroup\$ @JoseZaman He made Jelly BTW. \$\endgroup\$ – Erik the Outgolfer Oct 23 '17 at 14:26
1
\$\begingroup\$

PowerShell, 164 bytes

$a='136361616151315131531532513151315215436365213213315454521532545453153254541616';6..2|%{$a=$a-replace$_,(11,88,22,34,3332)[$_-2]};'7'*156+'1'*78+$a+'1'*78+'3'*39

Try it online!

String multiplication, concatenation, and replacements. PowerShell doesn't have base 36 or similar, so large-number compression options are limited. There might be a better way to "compress" the middle part -- I'm still checking on that.

\$\endgroup\$
1
\$\begingroup\$

Wolfram Language (Mathematica), 89 (17+71+1) bytes

First you export the number to a GZIP file. This file, named "o" with no extension will be exactly 71 bytes, which counts towards the total. By default, it will go to your $TemporaryDirectory. Omitting digits for readability.

Export["o",777777...,"GZIP"]

Then

"o"~Import~"GZIP"

will reconstruct the number. The file name is one byte so that's where the +1 comes from.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Ruby, 109 bytes

The script calls Zlib.inflate to decompress the number. It needs at least Ruby 1.9.3. It contains unprintable bytes, so I can't paste it here.

I paste the output of vis prime-inflate.rb:

require'zlib'
puts Zlib.inflate DATA.read
__END__
x\M-Z37\^_\M-<\M-@\M^P\M-:\M-@\^B
\M^PY\M^F\M-X\^XP\M-U\^X,d\^F\^^e\^H3pX\M^J\M-*\^L,\M^F\M-,\^A\M^C\M^Ea)\^Ve\M-X\M-\\M^F\M-"\^L\M^KO\M-)
\M^L\M^I\^C\^@\^P\M-p~\M-!

If you have unvis(1), run unvis prime-inflate.vis > prime-inflate.rb to restore the 109-byte script. Or you can decode the Base64, below, with ruby -e 'print *STDIN.read.unpack(?m)' < prime-inflate.b64 > prime-inflate.rb.

cmVxdWlyZSd6bGliJwpwdXRzIFpsaWIuaW5mbGF0ZSBEQVRBLnJlYWQKX19F
TkRfXwp42jM3H7zAkLrAAgqQWYbYGFDVGCxkBh5lCDNwWIqqDCyGrAGDhWEp
FmXY3IaiDItPqQqMiQMAEPB+oQ==

I call Zlib.inflate so I don't need to design and golf my own decompression algorithm. I use DATA with __END__ because the compressed string isn't valid UTF-8. Ruby code must be valid ASCII (in Ruby 1.9.x) or UTF-8 (from Ruby 2.0) or have a magic comment #coding:binary to change the encoding, but Ruby doesn't check the encoding after __END__.

\$\endgroup\$
1
\$\begingroup\$

Python 2, 112 bytes

print'7'*156+'1'*78+bin(int('JAOKI5B0O6K9IWDU8P76KDLR0VZMNWQ2WB9D8BOS8',36))[2:].replace('0','88')+'1'*80+'3'*39

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Befunge-93, 500 bytes

v F         >20g1-20p
>"3"20g10g`#^_>52*"F"20p30g10g`#v_"^!1"21p30p84*2+1p
^                       p03-1g03<
^>"81118888888811888888881>!"30p84*2+1p52*
^^"8888811188888811"*25"188111118"<>">#7"21p30p57*5p
>*"188111188188111188188111118818"^ $>:#,_@
^25"18811111881881111188188111111"<
>"8888811888888881"25*"1111111881"^
^"88811881111111881118888"*25"188"<
>"1188111111188111111118811111111"^
^"11881"*52"188111111118811111111"<
>"11111881"52*"188111188188111188"^
^"1118811111111188888811188888811"<

Try it online!

\$\endgroup\$
1
\$\begingroup\$

C (gcc), 188 187 185 181 176 156 bytes

-1 thanks to JonathanFrech.

-2 -4 thanks to ceilingcat.

x;r(d,n){for(;n--;)printf("%d",d);}f(i){r(7,156);r(1,79);for(i=38;i--;r(1,x%10))x="PS10*,),00*,/00=+/ff0/)-)-*,),)-)-SSgf"[i]-20,r(8,x/10);r(1,80);r(3,39);}

Try it online!

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Welcome to PPCG, nice first answer! \$\endgroup\$ – ovs Nov 7 '17 at 19:15
  • \$\begingroup\$ I think you can shift your string to get to a string which does not need escaping a backslash, resulting in 187 bytes. \$\endgroup\$ – Jonathan Frech Nov 7 '17 at 21:03
  • \$\begingroup\$ @JonathanFrech Ah, nice one! \$\endgroup\$ – gastropner Nov 8 '17 at 11:56
  • \$\begingroup\$ @ceilingcat Good catch! \$\endgroup\$ – gastropner Aug 21 '18 at 5:52
0
\$\begingroup\$

Python 2, 244 128 120 bytes

-8 bytes thanks to @JonathanFrech

s='1'*78
print'7'*156+s+bin(int("8zlghh9gqo74zwzntkcjmoou35vvlbg1cmasrm6ny1iafcvw568sj",36))[2:].replace(*'08')+s+'3'*39

Try it online!

\$\endgroup\$
1
0
\$\begingroup\$

///, 180 bytes

/~/\/\///P/IH~O/1G~N/1J~M/AA~L/77~J/IB~I/88~H/11~A/LLLLLL~B/HHH1~C/333333333~D/BB~E/III~F/H1I~G/F1/MMMMMMADDDDDBHEPEP1EH1EGOPGIOIO1PGPGJJ1EPEPJIFINNNIONN1IOIONNHEH1EDDDDDBH1CCCC333

Try it online!

\$\endgroup\$
0
\$\begingroup\$

FEU, 178 bytes

a/lllmtwrzxyzrrszwqqwqqwzqwzxzwqqwqqwszvyzxyzxzwszszzqvzvzwszwzxzvzvzwzqwzxzvzv1yrtvooop
m/l/mmmm/m/nnn/n/7777/o/pppp/p/333/q/1z/r/sy/s/x1/t/uuu/u/vvv/v/ww/w/xx/x/11/y/zzz/z/88/g

Try it online!

Compression. My compression testing wasn't very rigorous, so this might be able to be optimized.

\$\endgroup\$
0
\$\begingroup\$

brainfuck, 531 503 bytes

-[>+>+<<-----]>++++>-->---[>+<+++++++]>++>>++++++++++<<<++++[->[>+<-]>[<<<<.>>>+>-]>.<<<]++[->[>+<-]>[<<<.>>+>-]>.<<<]<<+>>++[-<.<........>.>]++[-<..<......>.>]<.>>>>.<<<++[-<.<..>.....<..>>]++[-<.<..>....<..>>]<.>>>>.<<<++[-<.<..>.....<..>>]++[-<.<..>......>]<.>>>>.<<<++[-<.<........>.>]<.<..>.......<..>...<....>>>>>.<<<+++[-<.<..>.......>]<<..>....<..>.>>>>.<<<++[-<.<..>.......>]++[-<.<..>....<..>>]<.>>>>.<<<++[-<.<..>.......>]++[-<..<......>.>]<.>>>>.<<<++[->[>+<-]>[<<<.>>+>-]>.<<<]<++>>[-<<.>>]

Try it online!

\$\endgroup\$
0
\$\begingroup\$

05AB1E, 148 bytes

•d•Å3•Θ•Å1ì•2œP²IM›BŽт›ÖΛZY
‰ øÕŒQÉΓΩr‡'?₁0rºн∊÷ζì‰ÉöΘ…çнEîx5›иñĽü’üΔιàòEγ®é∍NaV†Sƒ¯%à˜PÝ™₆·à≠ø€ćËÙzLtp:Ö†p\nJ$gāböò_¿®₂@h”•rª•Δ•Å1ìƵtÅ7컶õ.:ðõ.:

Try it online!

Explanation

•d•Å3•Θ•Å1ì•...•rª•Δ•Å1ìƵtÅ7컶õ.:ðõ.:
•d•Å3                                  push 39 "3"s
     •Θ•Å1                             push 80 "1"s
          ì                            merge lists
           •...•                       compressed number containing the "1"s and "8"s (probably could be shortened)
                r                      reverse stack
                 ª                     append
                  •Δ•Å1                push 79 "1"s
                       ì               merge everything
                        »              convert list to newline separated string
                          ¶õ.:         replace newlines with nothing
                              ðõ.:     replace spaces with nothing
                                       (implicit print)

Definitely can be golfed...

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy