De toute évidence, le golf par code consiste à tirer le meilleur parti du moins de code. Qui se soucie vraiment de la sortie réelle?
Bien que nous ayons eu un défi pour le rapport entrée-sortie le plus élevé , il s'agit d'un appel à la sortie la plus finie et déterministe avec des longueurs de code données. Ironiquement, ce défi n'est donc pas du code-golf .
Règles:
Écrivez trois extraits indépendants (pas des programmes / fonctions complets).
Les extraits doivent être dans la même langue.
Le score est le nombre total d'octets sortis.
Les sorties peuvent être sous la forme d'un résultat, STDOUT, etc.
Les extraits de code peuvent ne provoquer aucune erreur.
Les extraits peuvent provoquer différentes formes de sortie.
Les caractères de fin de ligne ne sont pas comptés.
Le premier extrait doit être de 1 octet ou la longueur minimale qui produit au moins 1 octet de sortie.
Le deuxième extrait doit être un octet de plus que cela.
Le troisième extrait doit être plus long de deux octets que le premier.
Réponses:
gs2, 412 + 5,37 * 10 902 + 10 10 903,1 octets
f
pousse1\n2\nFizz\n4\nBuzz\n...\nFizzBuzz
comme une412
chaîne de -byte.fô
imprime toutes ses permutations, donc des412! * 412
caractères.fôô
imprime toutes les permutations de cette liste d'éléments 412!, où chaque élément est long de 412 caractères, donc412 * (412!)!
octets.EDIT: Pour mettre les choses en perspective, c'est au moins
octets, éclipsant toutes les autres réponses jusqu'ici.
la source
Pyth, 26 + 1140850688 + (> 4,37 × 10 20201781 )
Je n'ai aucune idée s'il est possible de calculer la longueur exacte de la sortie pour le troisième programme. Je ne peux que donner des limites. Il imprimera quelque chose entre les caractères
4.37 × 10^20201781
et1.25 × 10^20201790
.Cela imprime:
Le premier imprime l'alphabet, le second tous les sous-ensembles de l'alphabet et le troisième les sous-ensembles des sous-ensembles de l'alphabet, qui est une liste de longueur
2^(2^26) ~= 1.09 × 10^20201781
.De toute évidence, aucun ordinateur ne pourra jamais calculer cette grande liste et la produire.
la source
CJam, 17 + 34 + 72987060245299200000 = 72987060245299200051 octets de sortie
Pour une comparaison plus facile, il s'agit d'environ 7,3 * 10 19 .
Tirages:
Eh bien, la dernière consiste en toutes les permutations
[0 1 2 ... 19]
avec les nombres écrasés ensemble. Je ne recommanderais pas de l'essayer ... (Essayez comme4e!
pour avoir un avant-goût.)Testez-le ici: programme 1 , programme 2 , version saine du programme 3 .
la source
Gelée , 1,2 × 10 2568 octets de sortie
Calcule 1000 , 1000 1000 et 1000 1000!.
Essayez-le en ligne: premier programme | deuxième programme | troisième programme (modifié)
À des fins de comptage d'octets,
ȷ
peut être codé comme l'octet 0xa0 dans la version actuelle de Jelly .Comment ça fonctionne
Dans Jelly,
ȷ
peut être utilisé à l'intérieur des littéraux numériques comme Pythone
(notation scientifique). Par exemple,3ȷ4
renvoie 30000 . Dans la notation scientifique de Jelly, le coefficient par défaut est 1 et l'exposant par défaut 3 , doncȷ
,1ȷ3
et1000
tous renvoient le même nombre.la source
⍳
?ı
estR
(plage).ı
etȷ
faire quelque chose de totalement indépendant dans Jelly. J'ajouterai une explication dans quelques minutes.ȷRR
cause-t-il?ȷRR
est⍳¨⍳1000
. Je voulais⍳⍳1000
. Dans Dyalog, il⍳⍳7
obtient 91244,⍳⍳8
803487 et⍳⍳9
7904816, car il répertorie tous les indices dans un tableau 1 × 2 × 3 × 4 × .... Donc⍳⍳1000
, théoriquement (WS FULL!) Générerait un tableau de! 1000 listes de 1000 éléments chacune!Hexagonie , 1 + 3 + 6 = 10 octets de sortie
Bon ... pas un score très impressionnant, mais au moins je peux affirmer que c'est optimal. Avec un seul octet, il est impossible d'imprimer quelque chose et de terminer, nous commençons donc avec deux octets:
Le code déplié est
Cela imprime un octet et se termine.
Pour trois octets de code, nous pouvons imprimer trois octets de sortie. Par exemple:
ou déplié:
impressions
111
. Toute lettre minuscule ded
àz
fonctionne et imprime son code de caractère. Ce sont les 23 seules façons d'imprimer 3 octets avec 3 octets de code.Enfin, pour quatre octets, il existe 169 façons d'imprimer 6 octets. Puisqu'aucun d'eux ne fait quelque chose de plus intéressant (à l'exception d'un flux de contrôle impair) que la solution simple, je présenterai cela:
Déplié:
Tu l'as deviné. Il imprime
111111
.Comment savoir si elles sont optimales? J'ai adapté le forceur brut que j'ai écrit pour le catalogue de la machine de vérité pour rechercher une sortie finie maximale en 7000 cycles (je ne pense pas que vous puissiez écrire un castor occupé avec 4 octets, qui fonctionne pendant 7000 cycles mais se termine toujours plus tard.)
la source
12345
et s'arrêtent. . .pour la curiosité, vous comprenez.Sérieusement, 2025409 octets
1 octet:
(produit 11 756 octets de sortie)
2 octets:
Produit 153 717 octets de sortie
3 octets:
Produit 1 859 936 octets de sortie
Sérieusement, il ne comporte pas encore de choses comme "tous les sous-ensembles" ou "toutes les combinaisons", donc les scores sont relativement faibles à ce sujet.
la source
N
ce que cela fait pour produire autant de sortie?Python 3, 1 + 22 + 23 = 56
Production
Imprimez 9, puis la définition de
id
etabs
.la source
Labyrinthe , 1 + 2 + 4 = 7 octets
Un autre faible score, que je poste principalement parce que je l'ai prouvé optimal pour la langue.
Comme Hexagony, Labyrinth ne peut pas imprimer et se terminer avec un seul octet, nous commençons donc avec deux octets:
Imprime un zéro et se termine.
Pendant trois octets, nous ne pouvons pas battre la solution naïve:
Cela imprime deux octets avant de se terminer. Il existe quelques autres options, comme l'impression
-1
avec(!@
ou~!@
ou,!@
. Il existe cependant une solution plutôt cool qui utilise la rotation du code source:Cela imprime un zéro, puis décale la source pour devenir
@!>
. À ce stade, il frappe une impasse, se retourne et exécute le!
nouveau sur le chemin du retour, avant de se terminer.Pour quatre octets, c'est un peu plus amusant, car la seule façon d'imprimer 4 caractères est d'utiliser l'astuce ci-dessus:
Imprimez deux zéros, passez à
@!!>
, imprimez deux autres zéros.Dans tous ces cas, j'ignore que vous pouvez également imprimer un octet avec
\
ou.
, car ceux-ci imprimeront toujours exactement un octet, alors!
qu'ils en imprimeront au moins un et potentiellement plusieurs.la source
Bash, 1726 octets
(Je l'ai corrigé maintenant. Veuillez envisager de voter.)
1 octet :
"
Les sorties:
307 octets:
id
Les sorties:
1418 octets:
zip
(Imprime vers STDOUT)la source
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):
la source
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
la source
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:
la source
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):la source
..<@
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:
la source
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
la source
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.la source
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:
la source
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)
la source
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:
la source
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
.la source
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
la source
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.la source
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.
la source
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.
la source
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:la source
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.la source
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
.la source
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.la source
Perl 6, 53 (17 + 18 + 18) bytes
e
outputs-e
outputse*e
outputsla source
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.la source