Jelas, golf kode adalah tentang memanfaatkan kode paling sedikit. Siapa yang benar-benar peduli dengan hasil aktualnya?
Meskipun kami memiliki tantangan untuk rasio input-to-output tertinggi , ini adalah panggilan untuk output yang paling terbatas dan deterministik dengan panjang kode yang diberikan. Ironisnya, tantangan ini bukanlah kode-golf .
Aturan:
Tulis tiga cuplikan independen (bukan program / fungsi lengkap).
Cuplikan harus dalam bahasa yang sama.
Skor adalah jumlah total byte yang dihasilkan.
Output mungkin dalam bentuk hasil, STDOUT, dll.
Cuplikan mungkin tidak menyebabkan kesalahan apa pun.
Cuplikan dapat menyebabkan berbagai bentuk output.
Mengejar karakter baris baru tidak dihitung.
Cuplikan pertama harus 1 byte atau panjang minimum yang menghasilkan setidaknya 1 byte output.
Cuplikan kedua harus lebih panjang satu byte dari itu.
Cuplikan ketiga harus dua byte lebih panjang dari yang pertama.
Jawaban:
gs2, 412 + 5.37 * 10 902 + 10 10 903.1 byte
f
mendorong1\n2\nFizz\n4\nBuzz\n...\nFizzBuzz
sebagai412
string -byte.fô
mencetak semua permutasi, jadi412! * 412
karakter.fôô
mencetak semua permutasi dari daftar elemen-412 itu!, di mana setiap elemen panjangnya 412 karakter, jadi412 * (412!)!
byte.EDIT: Untuk menempatkan segala sesuatu ke dalam perspektif, ini setidaknya
byte, mengerdilkan semua jawaban lain di sini sejauh ini.
sumber
Pyth, 26 + 1140850688 + (> 4,37 × 10 20201781 )
Saya tidak tahu apakah mungkin untuk menghitung panjang output yang tepat untuk program ketiga. Saya hanya bisa memberikan batasan. Ini akan mencetak sesuatu di antara
4.37 × 10^20201781
dan1.25 × 10^20201790
karakter.Ini mencetak:
Yang pertama mencetak alfabet, yang kedua semua himpunan bagian dari alfabet, dan yang ketiga adalah himpunan bagian dari himpunan bagian dari alfabet, yang merupakan daftar panjang
2^(2^26) ~= 1.09 × 10^20201781
.Jelas tidak ada komputer yang dapat menghitung daftar besar ini dan mengeluarkannya.
sumber
CJam, 17 + 34 + 72987060245299200000 = 72987060245299200051 byte keluaran
Untuk perbandingan yang lebih mudah, ini adalah sekitar 7,3 * 10 19 .
Cetakan:
Nah, yang terakhir terdiri dari semua permutasi
[0 1 2 ... 19]
dengan angka-angka yang disatukan. Saya tidak akan merekomendasikan mencobanya ... (Cobalah seolah-4e!
olah untuk merasakan.)Uji di sini: Program 1 , Program 2 , versi program ware 3 .
sumber
Jelly , 1,2 × 10 2568 byte dari output
Hitung 1000 , 1000 1000 dan 1000 1000! .
Cobalah online: program pertama | program kedua | program ketiga (dimodifikasi)
Untuk keperluan penghitungan byte,
ȷ
dapat dikodekan sebagai byte 0xa0 dalam versi Jelly saat ini .Bagaimana itu bekerja
Dalam Jelly,
ȷ
dapat digunakan dalam literal bilangan sebagai Pythone
(notasi ilmiah). Misalnya,3ȷ4
mengembalikan 30000 . Dalam notasi ilmiah Jelly, koefisien default ke 1 dan eksponen default ke 3 , jadiȷ
,1ȷ3
dan1000
semuanya mengembalikan angka yang sama.sumber
⍳
?ı
adalahR
(rentang).ı
danȷ
melakukan sesuatu yang sama sekali tidak berhubungan di Jelly. Saya akan menambahkan penjelasan dalam beberapa menit.ȷRR
menyebabkan?ȷRR
yaitu⍳¨⍳1000
. Saya ingin⍳⍳1000
. Dalam Dyalog,⍳⍳7
skor 91244,⍳⍳8
skor 803487,⍳⍳9
skor 7904816, karena itu mencantumkan semua indeks dalam array 1 × 2 × 3 × 4 × .... Secara⍳⍳1000
teoritis (WS FULL!) Akan menghasilkan array! 1000 daftar dari 1000 elemen masing-masing!Hexagony , 1 + 3 + 6 = 10 byte output
Ya ... bukan skor yang sangat mengesankan, tapi setidaknya saya bisa mengatakan itu optimal. Dengan satu byte, tidak mungkin untuk mencetak sesuatu dan mengakhiri, jadi kita mulai dengan dua byte:
Kode yang tidak dilipat adalah
Ini mencetak byte dan berakhir.
Untuk tiga byte kode, kita dapat mencetak tiga byte output. Contohnya:
atau dibuka:
cetakan
111
. Setiap surat-kasus yang lebih rendah darid
kez
karya dan mencetak kode karakter. Itu adalah satu-satunya 23 cara untuk mencetak 3 byte dengan 3 byte kode.Terakhir, untuk empat byte, ada 169 cara untuk mencetak 6 byte. Karena tidak satupun dari mereka melakukan sesuatu yang lebih menarik (kecuali untuk aliran kontrol ganjil) selain solusi langsung, saya akan menyajikan bahwa:
Dibuka:
Anda menebaknya. Mencetak
111111
.Bagaimana saya tahu ini optimal? Saya mengadaptasi brute forcer yang saya tulis untuk katalog mesin kebenaran untuk mencari output hingga maksimum dalam 7000 siklus (saya tidak berpikir Anda dapat menulis berang-berang yang sibuk dengan 4 byte, yang berjalan selama 7000 siklus tetapi masih berakhir kemudian.)
sumber
12345
and halt. . .just for curiosity's sake you understand.Seriously, 2025409 bytes
1 byte:
(produces 11,756 bytes of output)
2 bytes:
Produces 153,717 bytes of output
3 bytes:
Produces 1,859,936 bytes of output
Seriously does not yet feature things like "all subsets" or "all combinations", so scores relatively low on this.
sumber
N
do that makes it produce so much output?Python 3, 1 + 22 + 23 = 56
Output
Print 9 and then the definition for
id
andabs
.sumber
Labyrinth, 1 + 2 + 4 = 7 bytes
Another low score, which I'm mainly posting because I've proven it to be optimal for the language.
Like Hexagony, Labyrinth can't print and terminate with a single byte, so we start with two bytes:
Prints a zero and terminates.
For three bytes, we can't beat the naive solution:
This prints two bytes before terminating. There are a few other options, like printing
-1
with(!@
or~!@
or,!@
. There is one pretty cool solution though which uses source code rotation:This prints a zero, then shifts the source to become
@!>
. At that point it hits a dead end, turns around, and executes the!
again on the way back, before terminating.For four bytes, it's a bit more fun, because the only way to print 4 characters is to use the above trick:
Print two zeroes, shift to
@!!>
, print another two zeroes.In all of these cases I'm ignoring that you can also print a byte with
\
or.
, because those will always print exactly one byte, whereas!
will print at least one and potentially several.sumber
Bash, 1726 bytes
(I fixed it now. Please consider upvoting.)
1 byte:
"
Outputs:
307 bytes:
id
Outputs:
1418 bytes:
zip
(Prints to STDOUT)sumber
MATL, 313
The current version of the language (3.1.0) is used, which is earlier than this challenge.
Code (predefined literal: produces number 2, which is implicitly printed):
Output (1 byte):
Code (produces number pi, which is implicitly printed with 15 decimals):
Output (17 bytes):
Code (numbers from 1 to 99, which are printed by default with spaces in between):
Output (295 bytes):
sumber
Processing, 39 bytes
Deterministic
1 byte:
Outputs
0
.9 bytes:
Outputs
3.1415927
29 bytes:
Outputs
processing.opengl.PGraphics3D
Non-deterministic, >= 129 bytes
>= 32 bytes:
Outputs
processing.awt.PGraphicsJava2D@ + [mem-address]
>= 32 bytes:
Outputs
processing.awt.PGraphicsJava2D@ + [mem-address]
>= 65 bytes: (Thank you to @anOKsquirrel for this suggestion.)
Outputs
sumber
JavaScript, 1 + 3 + 18 =
1822Not a very interesting answer but probably the best JavaScript is capable of.
Added 4 score thanks to @UndefinedFunction!
Outputs as text:
sumber
alert()
you get output ofundefined
(at least in Safari).alert(.1)
gives0.1
, andalert(1/9)
gives0.1111111111111111
alert
gives mefunction alert() { [native code] }
Befunge, 2 + 4 + 6 = 12
Any snippet shorter than length 2 either cannot output, or cannot terminate its output.
In Befunge,
.
outputs the top value of the stack as an integer, followed by a space. A space is not a newline, so it is included in the count. Additionally, the stack is "infinitely" filled up with 0's, so the programs output (respectively):sumber
..<@
prints 8 bytes.SmileBASIC, 1+4+10= 15 bytes
Program 1:
The shortest way to print something is with ? (PRINT) and a single character. This can be either a number or a variable name, and it doesn't matter since they're all the same length.
Program 2:
Now we have access to a few more things. The longest expression which can be made would be one of the constants #Y, #L, or #R, which have values 128, 256, and 512, respectively. However, instead of that, I use a comma so that (in this case) 3 extra spaces are printed.
Program 3:
With 3 characters, you can write E-notation numbers:
sumber
HQ9+, 71304
Prints the 11,884-character lyrics of "99 bottles of beer"
Prints "99 bottles of beer" twice
Prints "99 bottles of beer" three times
sumber
Japt
-Q
, Outputs1.0123378918474279e+150
bytesThe full number is
bytes.
# 1
Outputs
For 67 bytes. (Credit to Shaggy)
# 2
Outputs
which is 501 bytes.
(Credit to @Shaggy)
# 3
Outputs all permutations of the 95 printable ASCII characters in the format
["...","...","..."...]
, which isYou can get an infinite amount of output bytes if you use the
-F
flag in Japt. What it does is that if the last expression of the program evaluates to false, it outputs the value specified in the flag instead. So I guess the score for Japt-F"Insert Super Long String Here"
is infinity.sumber
undefined
in 1 byte:$
.K
and get 26 bytes of output, but your 501 byter is just geniusMalbolge, 1 + 2 + 3 = 6 bytes
Try it online: first, second, third
Outputs:
Brute forced. Assumes
\0
is not a valid output characterWith
\0
:Outputs:
sumber
scg, 1 + 27 + 188 = 216
First one:
Just prints 1, as the stack is outputted at the end of program.
Second:
Prints debug info, which should look like this:
Third:
adds 99 to stack, then uses range function. Outputs 01234567891011.... (this is one of those times I wish I implemented the factorial function. I haven't)
sumber
Marbelous 1 + 1 + 2 = 4 bytes of output
Marbelous is hamstrung here by having two-byte instructions. Pointless comments or unnecessary whitespace are the only ways to get an odd byte count.
print "A" and terminate:
print "B" and terminate, with an empty EOL comment
print "CD" and terminate:
sumber
Mathematica, 6 + 461 + 763 = 1230
1225618163bytes of outputCurrently, the last two use
Information
to get documentation about the symbols, which can output many bytes. Note that this was run on the 10.1 command-lineMathKernel
.sumber
Javascript, 72 bytes
This works in the Mozilla JSShell Javascript command line interpreter.
1 byte:
1
Outputs
1
35 bytes:
gc
Outputs
36 bytes:
run
Outputs
sumber
js
on the command line, you get a JavaScript shell.-bash: js: command not found
Please specify more.js
in the latest version of Bash.gc
doesn't seem to exist in TIO Node, so please find an implementation or remove this answer.Octave, 2818417 bytes
14 bytes for
ans = 2.7183\n
14 bytes for
ans = 3.1416\n
Display the entire documentation. 2818389 bytes, counted with
dd
Try it online! becauseevalc
didn't work.sumber
SmileBASIC 4, 1 + 13 + 15 = 29 bytes
This is going to be similar to 12Me21's SmileBASIC 3 answer, with a couple adjustments.
1
As before, the shortest amount of code to produce some output is 2 bytes:
?
(PRINT
) and some single-byte expression. The consensus is thatPRINT
does not produce a newline when it advances to the next line, due to the way the text screen works. So this results in one byte of output.2
With 3 bytes, we can do something different. SB4 introduces
INSPECT
, aliased as??
, which prints info about a single value. If we give it an empty string, for example, this can produce much more output than SB3 could. This gets us 13 bytes.3
We have 4 bytes to work with, so we have to decide what we should do to maximize our output. Going with
??
is a safe bet; we only have 2 bytes to use on our expression, but the additional output ofINSPECT
is basically free. So I use it to print a label string. This is 15 bytes.The total is 29 bytes.
sumber
Microscript II, 23+47+71=141 bytes
1:
C
The stringification of continuations is not strictly defined by the specs, but in the reference implementation this, run on its own, yields a 23 byte string.
<Continuation @t=\d\d\dus>
(\d
represents a digit, which digits varies).On my computer, at least, this does, in fact, always take between about 180 and about 400 microseconds to run.
The first use I've ever actually had for this instruction.
2:
CP
47 bytes of output- the output from the first one twice with a newline in between.
3:
CPP
Fairly straightforward. 71 bytes of output- the output from the first one three times with newlines in between.
sumber
PowerShell, ~4300 bytes
Approximate output length, given the system that it's run on. All the snippets below are deterministic, in that if given the same initial state of the computer will output the same text, just that in practice the output could change from execution to execution.
Length 1, 107 bytes
This is an alias for
Where-Object
. It will output a user prompt asking for additional information:Length 2, 113 bytes
This is an alias for
Remove-ItemProperty
. It will output a user prompt asking for additional information:Just barely longer than the length 1 snippet.
Length 3, ~4100 bytes
This is an alias for
Get-Process
which will output a formatted table of all running processes on the system:sumber
Javascript, 312 + 318 + 624 = 1254 bytes of output
The two functions
$
and$$
are available in all major browsers' consoles, as shortcuts fordocument.querySelector
anddocument.querySelectorAll
respectively. Different browsers have native code coerced to strings somewhat differently from each other, and IE uses plain JS in each function resulting in much longer representation.For the byte count, I'm taking the length of the string representation of each rather than the sometimes-modified console display, so the total bytes are, for each of the following browsers:
(I'm considering the IE result to be the "official" count because it's the longest.)
For non-console browser environments, the largest outputs come from the following:
Results length by browser:
{}
is usable) + 32 = 38 (or 48) bytes{}
is usable) + 38 = 44 (or 54){}
is usable) + 36 = 42 (or 52)These two sets of input produce the largest output possible in all of these browsers and consoles. To prove this, let's check all alternatives:
Object.getOwnPropertyNames(window).filter(x=>x.length<=3)
, and thenmap
them to their string outputs to determine the larger ones. (Note that in some browsers such as Firefox, certain special console variables cannot be accessed this way as they're not a property of the window.)1234567890
) optionally followed by.
and more decimal digits and/or an exponent part, or be a.
followed by one or more decimal digits and optionally an exponent part. Other kinds of numbers must be either0o
,0x
, or0b
(or uppercase forms), followed by one or more digits. For our purposes, we can deduce the following:$
, a comma, or a single-digit number. Arrays with only one element are coerced to strings as the element itself. Empty arrays become empty strings.{}
alone at the beginning of a script would be treated as an enclosure rather than creating an object.eval({})
returns undefined,eval({$})
returns the$
function. There are insufficient characters to surround the{}
in()
.if
,in
,do
,new
,for
,try
,var
, andlet
would all require a minimum of two other characters to use, exceeding the limit.~
,+
,-
,!
,++
, and--
. The two-character operators can only be used with a single character variable, of which there is only one ($
), which yieldsNaN
. The other four operators can be used with any one- or two- character value, of which there are:$
,$_
,$0
,$1
,$2
,$3
,$4
,$
,$$
,$x
). When used with these operators, the results are limited to-1
,true
,false
, andNaN
.true
,false
.-1
,0
(-0
becomes0
on toString),true
.+
,-
,*
,/
,%
,<
,>
,&
,|
,^
. They can only be used with a single-character value on each side. Options for values include$
and integers 0-9. Results of all combinations of these includeInfinity
, some numbers and binary values mentioned above, and numerous fractions which are coerced to strings of 19 characters or less (1/7
is 19 characters, unlike1/9
suggested above which is only 18), and the text representation of$
preceded or followed by a single-digit integer or itself..
requires an existing variable and a identifier referring to a property. All uses of this here result inundefined
. Surrounding a value in(
)
returns the value, as does assigning it with=
. Using()
or `` to call a value as a function results in undefined or errors with all available values.Adding all this up, there are a grand total of 1651 possible outputs when using a Chrome console. The longest outputs for one, two, and three characters are from
$
,$$
, and$+$
respectively.sumber
dc, 2+5+18=25 bytes
1:
Ff
yields (Try it online!):2:
Fdf
yields (Try it online!):3:
Fd^f
yields (Try it online!)None of which are particularly interesting, but
dc
isn't really great for spitting out piles of output. I do like that each answer builds on the previous. Anyway,F
is just the number 15;f
prints the entire stack;d
duplicates top-of-stack;^
raises next-to-top-of-stack to the power of top-of-stack (in this case, 15^15). I don't believe this can be topped indc
.sumber
Ruby, 3+14+28 = 45 bytes
Why did I do this.
Prints
nil
.Prints
#<IO:<STDOUT>>
.Prints something along the lines of
#<Object:0x0000000003610988>
.Launches an instance of Interactive Ruby. Upon exiting, the returned object is
#<IRB::Irb: @context=#<IRB::Context:0x0000000003643040>, @signal_status=:IN_EVAL, @scanner=#<RubyLex:0x00000000038900a0>>
for 121, but since it requires you to press^D
or something to actually exit the irb instance, I wasn't sure if it'd actually count as a solution in "3 bytes" so I'm not actually including it in the score unless it gets an OK.sumber
Perl 6, 53 (17 + 18 + 18) bytes
e
outputs-e
outputse*e
outputssumber
Runic Enchantments, 4,000,000 bytes of output
The first program is:
Takes 2 bytes to: push a value to the stack, print a value from the stack, and terminate. In this case it prints
10
(though any integer value from 0 to 16 are also just as valid)For 3 bytes:
Prints
10000
, Again,a
could be 1 through 16 inclusive (in order to generate more output than the original program, 0 is potentially valid under other operators) and there aren't a whole lot of operators that take a single input and produce any output, much less longer output.XCYZ:E
are the only real options.aY@
is just the one that results in the most output.According to language specification, this runs infinitely. However as the interpreter has a built in "ok, that's enough" maximum execution limit, this is the most output achievable in 4 characters (and TIO cuts off execution after ~130,000 bytes for exceeding 128kib) and as the interpreter defines the language, this works. And while I have raised that threshold once before (from 10k steps to 1 million), I don't plan on messing with it any time soon.
Bigger?
If I invoke the three assumptions I made here, then sure.
Which works out to
Ack(65,Ack(65,64))
, which aren't terribly large values to go shoving into the Ackerman function initially--certainly smaller than the 255 in the older post--but its ok, we can call Ack twice in 4 instructions.And only god knows what it'll print.
Note: the
A
instruction has since then been made theMath
meta-instruction, which consumes 3 objects on the stack: a char for what instruction to perform and then two inputs, x and y. As such this program doesn't actually do anything, both because neitherA
nor@
map to a math function and because two subsequent calls results in a stack underflow.sumber