New answers tagged

3

1087 bytes 1065 bytes Apparently the JDK's maxdepth limit is kinda broken... static Object payload() throws Exception { int layers = 30; int width = 2; int codes = 7; int extra = 8; List<Set<Object>> sets = new ArrayList<>(); sets.add(new HashSet<>()); for (int i = 1; i < layers; i++) { Set<Object> s = ...


2

This one’s 1207 bytes and performs 3910245742 hashes. private fun veryHashySet(): Set<Any> { val codes = listOf(Code(), Code()) val sets = mutableListOf<Set<Any>>() for (i in 0 until 16) { val limit = if (i == 15) 3 else 2 for (j in 0 until limit) { val set = HashSet<Any>() for (k in 0 until 4) { ...


8

x86-64 machine code (Linux system calls), 29B * 4.7/6.6 = ~20.6 on tmpfs on Skylake Yes, this runs faster than GNU yes on tmpfs, the widely-used Linux ramdisk-like filesystem backed by the pagecache. I made sure to align my buffer to at least a cache-line boundary (and in fact a 4k page boundary) so the kernel's copy_from_user memcpy-like function using ...


1

05AB1E (legacy) / 05AB1E, 4 bytes, score: waiting for OP ['y, Or alternatively: 'y[= Try it online. Not sure which combination is the shortest, so for now this answer has four possible variations: 05AB1E (legacy) with program ['y, 05AB1E (legacy) with program 'y[= 05AB1E with program ['y, 05AB1E with program 'y[= The 05AB1E (legacy) version is ...


1

Rust, 49 bytes \$\times\,\frac{31952896}{772800512}\approx2.025\$ Plain Rust, compiled with -C target-cpu=native -C opt-level=3. Clearly not the winner, only for reference; not bad, btw :) fn main(){loop{print!("{}","y\n".repeat(8192));}} Try it online!


0

C (clang), 57 54 bytes \$\times\frac{44152832}{45940736}\approx51.8984\$ Saved 3 bytes thanks to @S.S.Anne!!! #define p putchar_unlocked main(){for(;;p(10))p('y');} Try it online! This is on my ancient tablet, probability better on my laptop that's far away right now - on holiday! :))))


6

Python 3, 79 digits (probably optimal) A simple depth first search that allows up to two consecutive zeros. from sympy.ntheory.primetest import isprime def dfs(n=0, k=1): yield n if 100*n > k: yield from dfs(n, k*10) for i in range(1,10): if isprime(k*i + n): yield from dfs(k*i + n, k*10) l = 1 for prime in dfs()...


2

Charcoal, 32 bytes F37⊞υιFυFE⁹⁺⊕κι¿⬤…²Iκ﹪Iκλ«κD⎚ Try it online! Finds all zero-free recurring primes, but is inefficient, so the TIO link is limited to just under 60 seconds' worth of primes. Explanation: F37⊞υι Start with the two possible last digits of all recurring primes (except the trivial 2 and 5). Fυ Perform a breadth first search of recurring ...


1

x86-32 Linux, 26 bytes (ungolfed), 1.5M write syscall test. Produces a very underwhelming result. main: push $0x0A79 # "y\n" mov $1, %ebx # write to stdout (fd=1) mov %esp, %ecx # use chars on stack mov $2, %edx # write 2 chars loop: mov $4, %eax # sys_write call number int $0x80 jmp ...


7

Bash, 16 bytes, 16TB output, score ~0 .0018554687 Thoroughly abuses the rules trap '' TERM yes It ignores timeout's SIGTERM (running an empty command) and so continues beyond the 1 second that the benchmark script intended to set. This will fill your disk unless you kill it with a different signal or set a quota or other size limit.


1

Japt, 6 bytes No clue how the scoring in this challenge works. @Opy}a Try it online! @ :Function Opy : Print "y" } :End function a :Call repeatedly until it returns a truthy value :(Japt's O.p() method returns undefined)


3

C (gcc), -O3 -funroll-all-loops 66 bytes * 393M/527M ~= 49 b[1<<16];main(){for(wmemset(b,'\ny\ny',1<<16);write(1,b,1<<18););} Your times may vary. I'm running this inside a VM on a weak computer. b[1<<16]; is an integer array of \$2^{18}\$ bytes. wmemset(b,'\ny\ny',1<<16); sets that array to a pattern of y\ny\n. The ...


0

Lua 25 22 bytes thanks S.S Anne while 1 do print"y"end Try it online


2

Python 3, 34 bytes, 1.9GB/s, score ≈ 32.711 a='y\n'*2**17 while 1:print(end=a) Try it online!


-1

Python 3, 18 bytes \$\times\frac{16834568}{622668}\approx486.65\$ while 1:print('y') Try it online!


0

Ahead, 36/2 = 18 bytes! Prints then divides by zero. The error contents contain a copy of the codeboard, so the string Goodbye Cruel World! will appear. "!dlroW olleH"W/Goodbye Cruel World! Try it online! Ahead, 24 bytes Same but doesn't get the bonus. "!dlroW leurC eybdooG"W/ Try it online!


34

C, 112 bytes, 28 TB/s, score ≈ 0.008 long b[9<<21];main(){for(b[2]=write(*b=1,wmemset(b+8,'\ny\ny',1<<25),1<<27)/2;b[3]=b[2]*=2;ioctl(1,'@ ”\r',b));} (If you’re having trouble copying and pasting this, replace the multicharacter constant '@ ”\r' with '@ \x94\r' or 1075876877.) This writes 128 MiB of y\ns to stdout, and then ...


3

Perl 5 (cperl), 26 bytes while(1){print"y\n"x 9**4} Try it online! R, 18 bytes repeat{cat('y\n')} Try it online! Improved thanks to @JDL Squirrel, 24 bytes while(1){::print("y\n")} Try it online! JavaScript (Node.js), 26 bytes while(1){console.log('y')} Try it online! Python 3, 28 bytes while1:print(end='y\n'*9**4) Try it online! Julia 1.0, ...


28

Bash, 3 bytes, 1.9 GB/s yes Try it online! Admittedly this is a troll solution, but the rules do not explicitly forbid it, and it should get you a value close to 3, which is not bad.


10

C (clang), 88 63 bytes, 2.5GB/s b[2048];main(){for(wmemset(b,'\ny\ny',2048);write(1,b,8192););} Try it online! Edit: Saved 25 bytes thanks to @ceilingcat by assuming 4-byte wide characters.


2

PHP, 75% foreach(count_chars($argn)as$c)$o[]=$c*'1111111111111111111111111111111111111111001111111111111111111111111111111111111111111111111010111111111111111111111111111110101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'[$i++];arsort($o);echo chr(key($o)); Try it online! ...


5

05AB1E, 99.999999999999999957% 1111111111111111111 ... (9352835025086960662 1's total) ... 11111g₅B.V g gets the length of the large integer literal. Obviously this is too long for TIO, so try a version using 9352835025086960662 instead of the equivalent 1111...1111g.


1

05AB1E, tends to 50% '""{}[]()"'""м.M"J".V"".V"".V".V Try it online! You can keep appending ".V" before the final J, any part of this string can't be removed and hence none of the characters themselves are non-trivial. Hence this tends to 50% of the program being " as you add more ".V" Note: you couldn't have a single char command to tend to 66% inside ...


0

C (gcc), 13.2% ; float m;a[256];l;t;c;n(char*s){bzero(a,1024);l=0;for(;*s;){a[*s]++;s++;l++;};m=0;t=0;for(;t++<255;)if(a[t]>m)c=t,m=a[t];m*=100;printf("%c %f\n",c,m/l);} This version doesn't pad the end with semicolons. It only contains a few unneeded ones to push up my score to the next percent. Feel free to add semicolons up until you get 100%. ...


2

JavaScript (Node.js), 55.85% (or much more) s=>eval(Buffer((g=n=>n?[+[n&127n],...g(n>>7n)]:[])(...


1

Python 3, 33 31 print('Goodbye Cruel World!') e very basic Try it online! Python 3, 23! 19! print('Hello World!') Goodbye Cruel World! Try it online!


11

Python 3, score = big(?) from math import exp, log, log1p def f(b, n): e = n * (n - 1) / 2 m = 0 c = 1 s = 0 t = 1 << b for k in range(b): s += c m += exp(e * (log1p(-s / t) if 2 * s < t else log((t - s) / t))) c = c * (b - k) // (k + 1) return m Try it online! The Hamming distance \$D_{x, y}\$ ...


1

Jelly / 05AB1E / Whitespace, 14 bytes, score \$0.\overline{518}\$ [S][S][S][T][T][LF] [T][LF] [S][T]1o [S], [T], and [LF] added for visual clarity only. I was going to add naz to the chain, but I guess it doesn't handle whitespace very well. Jelly explanation [S][S][S][T][T][LF] [T][LF] [S][T] 1 # Literal 1 o # ...after which the ...


2

Bash + bc, 89 bytes, arbitrary precision, final score \${89\over3} \approx 29.67\$ f(){ a=`primes 1 $((${1%.*}+1))|wc -l` echo "scale=$a+20;a=$1/l($1);scale=$a;a/1"|bc -l } Try it online! ${1%.*} strips off the fraction $(( ... +1))) adds one, as primes doesn't output the final number if prime. primes 1... outputs the list of primes |wc -l counts them ...


2

bc, 61,51,46,45 bytes +2 for -l, (almost) arbitrary precision, final score \$\approx{47\over3} \approx 15.6666744835...\$ define f(x){scale=999 return(scale=x/l(x))/1} Try it online! Unlike the test cases, I don't give too many digits. I give the number of digits based on the approximation, not the counted value. Precision degrades with this solution ...


1

C (gcc), 66 bytes, period 2^64 f(s){printf(s="f(s){printf(s=%c%s%1$c,34,s,%lu+1L);}",34,s,0+1L);} Try it online! 2^64 numbers are available in a unsigned long integer. Therefore, a period of 2^64.


3

05AB1E, 17 14 bytes - Score = 22.6... 18.6... -3 bytes/4 score thanks to Kevin Cruijssen žr.n÷'.0IÅPg×J Try it online! As far as I'm aware 05ab1e doesn't have arbitrary length decimal precision. You can probably come up with an answer which calculates pi(x) decimal points of x/log(x) in less than 68 bytes and then concats them but frankly I'm not ...


3

Python 3, 61 bytes \$\approx\$ 77.6375 score import math def f(x):p=x/math.log(x);print(f"{p:.{int(p)}f}") Try it online! Correct up to 4 decimals for \$\pi(10)\$. Original post solution: Python 3, 41 bytes \$\approx\$ 54.66 score lambda x:int(x/__import__('math').log(x)) Try it online! Saved 20 bytes thanks to Expired Data!!! Taking a leaf out of ...


1

Mathematica, \$\approx\$ 7.67 score 25 23 bytes, arbitrary precision, final score \$ \frac{23}{3}\$ N[#/Log@#,PrimePi@#+1]& -2 bytes, courtesy of @ExpiredData Here is a benchmarking solution. Try it online!.


1

Python 2 Period: \$9\uparrow((99\uparrow\uparrow(9\uparrow((99\uparrow\uparrow(9\uparrow((99\uparrow\uparrow(9\uparrow\uparrow5-1))\uparrow9)-1))\uparrow9)-1))\uparrow9)+1\$ Thanks to @Bubbler for increasing period from \$9\uparrow9\uparrow(99\uparrow\uparrow12)+1\$ to now b=0;s="print'b=%d;s=%r;exec s'%(-~b%eval('9**9'*eval('9**9'*eval('9**9'*9**9**9**9**...


1

Python 2, 57 bytes, 16444 ≈ 4.258 \$\times\$ 10534 iterations -1 byte and \$\times\$16 iterations thanks to @AndersKaseorg b=0x0;s="print'b=%#x;s=%r;exec s'%(-~b%4**888,s)";exec s Increments a hexadecimal counter on each iteration and when it reaches \$16^{444}\$ it resets to \$0\$ Try it online!


2

naz, 46 bytes, score 32.2 2a2a1o2m1o7s1o5m1o2s2s1o6m1o2s2s1o1a1o1a1o2s1o Simply outputs each digit in 4815162342 one at a time.


0

Red, 14 bytes all versions system/version


2

Python 1, 2, and 3, 43 bytes, score 14.333 if str(1<2)=="1":print(1) else:print(3/2*2) Yes, there are already submission for Python, but this one also differentiates Python 1 and 2. The difference between Python 3 and 2 are pretty well known, but with Python 1? It's very similar to Python 2. But I found something. In Python 1, a true statement ...


1

Pyth, 18 numbers 579 t Another challenge where being infix rather than prefix would be nice. This uses the space to "hide" some of the numbers and the decrement to get more numbers. Here's all of the outputs. [ 57 t9 ] => '57' [ 57t 9 ] => '57\n8' [ 59 t7 ] => '59' [ 59t 7 ] => '59\n6' [ 5 7t9 ] => '5\n8' [ 5 9t7 ] => '5\n6' [ 5 t79 ] =&...


10

05AB1E, 10 ... 172 distinct bytes \]^_abcdefghiijklmnopqrstuvwxyz{|}}}~ƵƵ€Λ‚„…†‡ˆ‰ŠĆĆĆŽƶĀ‘‘’’““””••–—™š›œćŸā¡¢¢¢¤¤¦§¨©ª«¬®¯°±´¶·¸º»¼½½¾¿ÀÁÁÂÃÄÅÇÌÍÐÐÐÐÐÐÑÒÓÔÕÖ×ØÙÚÛÜÝßàáâãäåçèéêëìíîïðñòóôõö÷úü -.0123456789;<>@ABCDDDHKKOPQRSTUVWXYZ Try it online! or validate all test cases (note: the "all test cases" version omits ] and ë, since those don't play well ...


1

Burlesque, 1000 or 1111111 1e3 1cy7.+ Try it online! First the boring method just printing 1000, or making an infinite number of 1s and clipping it to the length of the code+1.


0

Fortran (GFortran), 24 ones print*,("1",i=1,23) end Try it online! Better Fortran score by avoiding formats entirely.


1

naz, 100,000,000 11,111 1a5o Explanation 1a5o # Output "1" five times I slightly misunderstood the question at first — here's my original 8-byte solution: 1a1o1s8o


Top 50 recent answers are included