The Challenge

Write a complete program that writes twice as many bytes to standard output as the length of the program.


  • The program must write ASCII characters to the standard output.

  • The contents of the output doesn't matter.

  • The output, measured in bytes, must be exactly twice the length of the program, also measured in bytes, unless you fulfill the bonus.

  • Any trailing newline is included in the output's byte count.


Your program can optionally take a number, n, as input. If so, the output must be exactly n * program length bytes. You can assume that n will always be a positive integer. If no input is provided, n must default to 2.

If you do this, you can subtract 25 bytes from your score.

Shortest program wins.


  • No standard loopholes.

  • The program must be at least 1 byte long.

  • No adding unnecessary whitespace to the source code to change its length. Similarly, comments don't count.

  • Unless you fulfill the bonus, the program must accept no input. If you do fulfill the bonus, the integer must be the only input.

Lowest score (program length in bytes - bonus) wins.

The shortest answer for each language wins for that language.


Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.


# Language Name, N bytes








  • 1
    \$\begingroup\$ For the bonus, does the output have to be exactly n * program length bytes, or is that a minimum? \$\endgroup\$ – xnor Oct 2 '15 at 23:19
  • 2
    \$\begingroup\$ It has to be exact \$\endgroup\$ – Daniel M. Oct 2 '15 at 23:20
  • 3
    \$\begingroup\$ Looks like the code snippet has to be modified to handle negative scores. \$\endgroup\$ – El'endia Starman Oct 2 '15 at 23:49
  • 40
    \$\begingroup\$ A bonus of -25 is basically mandatory for some languages, since it lets them achieve a negative score. In the future, I'd suggest using a percent bonus, or just making the bonus the question if you really want answers to go for it. Or, just don't have a bonus. \$\endgroup\$ – xnor Oct 2 '15 at 23:58
  • 4
    \$\begingroup\$ For "no input is provided", do we assume the empty string is passed in? I can't see how one would deal with the user never typing in an input and the program just waiting. \$\endgroup\$ – xnor Oct 2 '15 at 23:59

260 Answers 260


q (bonus), 27 bytes


C#, 104 bytes (79 point with bonus)

class a{static void Main(string[] p){System.Console.Write(new System.String('1',104*int.Parse(p[0])));}}

you can run the program by using an argument for example test.exe 2 prints 208 character '1'

  • 1
    \$\begingroup\$ I think there's one rule missing: If no input is provided, n must default to 2 \$\endgroup\$ – Thomas Weller Oct 7 '15 at 20:30

Befunge-98, 26-25=1


Run it in this interpreter. Apparently, it can't take input.

Befunge-93, 30 - 25 = 5 27-25=2


There is a trailing space on the first line, and this is done because it's shorter to make 27 than it is to make 26 with Befunge-93. This outputs 27*n 1s in a row.


Perl, 10 9 bytes

Uses @primo's suggestion of $=.


$= is a shortcut for $FORMAT_LINES_PER_PAGE, which defaults to 60.


$ cat doubler.pl
$ perl doubler.pl
  • 1
    \$\begingroup\$ print$=x9 for one byte. \$\endgroup\$ – primo Oct 3 '15 at 8:35
  • 1
    \$\begingroup\$ I think print$~x3 also works for the same score. On my system, it outputs STDOUTSTDOUTSTDOUT. \$\endgroup\$ – PhiNotPi Oct 3 '15 at 19:55

Stuck, -13 Bytes


This prints a bunch of newlines (N). Empty input is considered to be 0 (or anything less than 0). So, if 4 was given, it will print 48 newlines.

Old Answer - 3 Bytes


will output


Will be giving the bonus a shot.


C, 25


This makes use of UB, but it should work. At least it works with gcc 5.2.0


MSM, 12 bytes




R, 3 bytes


will print

[1] 10

QBasic, 2 bytes


Nonnegative numbers in QBasic are output with both a leading and a trailing space. The PRINT command (for which ? is a shortcut) outputs a newline by default. Thus, I count 4 bytes of output: space 1 space newline.


Julia, 9



"WARNING: issubset\n"
  • \$\begingroup\$ Might want to format your header differently so your score doesn't look like -8 instead of 9 \$\endgroup\$ – Patrick Roberts Oct 5 '15 at 4:05

Insomnia, 1




8, A, B are 3 other programs that satisfy the requirement. Their output contains NUL characters, though.


MUMPS, 4 bytes

w ?8

Well, I'm not sure if this really counts. What this program does is advance the output cursor 8 characters to the right. On every terminal I've used, this is indistinguishable from outputting 8 spaces, but is it really the same thing? I dunno.


C, 82 bytes (with bonus)

main(int a,char**b){b&&b[1]&&(a=atoi(b[1])-1);a&&main(a-1,0),printf("%.80f",.0);}


$ wc main.c
       1       2      82
$ ./a.out | wc
       0       1     164
$ ./a.out 4 | wc
       0       1     138
$ ./a.out 133475 | wc
       0       1 10944950
  • \$\begingroup\$ I think you can shave some off by modifying b as you go: b&&*++b&&(a=atoi(*b)-1) \$\endgroup\$ – Toby Speight Oct 6 '15 at 10:31
  • \$\begingroup\$ Yes comrade! It does work. \$\endgroup\$ – wefwefa3 Oct 6 '15 at 17:43

DOS, 7 bytes

date /t

outputs di 06-10-2015 (and a newline) on my system, but I'll admit it's locale dependent. So my second best is:

echo %PATH:~0,33%

which outputs C:\WINDOWS\system32;C:\WINDOWS;C: (and a newline).

  • \$\begingroup\$ With my system settings it prints 2015.10.07\n \$\endgroup\$ – SuperJedi224 Oct 7 '15 at 10:12
  • \$\begingroup\$ Got 6.2 bytes using "type %0". \$\endgroup\$ – Star OS Dec 16 '15 at 12:03
  • \$\begingroup\$ @StarOS That gives me The system cannot find the specified file (roughly translated) \$\endgroup\$ – Berend Dec 17 '15 at 7:45
  • \$\begingroup\$ Berend, it only works in a Batch file. +1 beacuse all of the other things don't use a shell, it uses a file \$\endgroup\$ – Star OS Dec 17 '15 at 11:25
  • \$\begingroup\$ @Berend Note, you are using Windows Batch, not DOS Batch. The string manipulation function is added in Windows, not DOS. \$\endgroup\$ – stevefestl Sep 22 '17 at 23:52

Bash + GNU coreutils, -1 byte

printf %24s `seq ${1-2}`

Score is 24-25

A non-bonus version for +5:

seq 5

which produces 1 nl 2 nl 3 nl 4 nl 5 nl.


Bash + GNU coreutils, 26 24 - 25 = 1 -1 byte

The x file:

yes|head -c$[24*${1:-2}]

(no trailing newline)


$ bash x 1 | wc -c
$ bash x | wc -c
$ bash x 3 | wc -c

Old version with 26 bytes:

The x file:

yes|head -c$((26*${1:-2}))

(no trailing newline)

  • \$\begingroup\$ @Unihedron I don't see how this violates that rule. \$\endgroup\$ – Doorknob Oct 4 '15 at 14:30

POSIX bc, 4 bytes


This creates the output 10000000.


Javascript, 3 bytes!


Returns 100000. Y'all JS golfers are overthinking it!


CJam, 1 byte


Prints 10. Very straightforward.


Pyth, 4 bytes


will print out

  • 1
    \$\begingroup\$ Why did someone EDIT my answer??? \$\endgroup\$ – Erik the Outgolfer Oct 7 '15 at 15:25
  • \$\begingroup\$ I like how you rolled back their changes and then added them back in. \$\endgroup\$ – Luminous Oct 9 '15 at 12:53
  • 1
    \$\begingroup\$ @Luminous I did it because I want editors to learn not to edit my answers. They can suggest in comments instead! \$\endgroup\$ – Erik the Outgolfer Oct 10 '15 at 12:41
  • 1
    \$\begingroup\$ Well the thing in this case was that editor didn't just edit your answer. They changed it to be completely different. They should've made it another answer. Other wise you shouldn't feel like your answer is being violated if someone edits it. We can edit other people's answers for plenty of reasons. \$\endgroup\$ – Luminous Oct 11 '15 at 14:43
  • \$\begingroup\$ @Luminous Yeah, and I added them back in because I got that as a suggestion. But if they do not have rep to comment then they should add just a small not on the bottom of the answer but not EDIT it. \$\endgroup\$ – Erik the Outgolfer Oct 12 '15 at 11:33

[this is a sticky note] This answer has multiple versions.

Due to the fact that I honestly am not quite sure what "input" means here. The first is the one I would use to score myself. Go down to the second to find an explanation. For scoring 1 point, do I tie with the Matmematica one? Or for scoring -1 (-5?) points, do I win? Hmm.

Anywho, this was quite a fun challenge. Maybe I can make my answer a bit better but anyways.

Python 2.7, 26 - 25 = 1

If input means input from stdin:


Python 2.7, 24 - 25 = -1

If input means a variable:



n=2                   # Set a variable n to 2
;                     # Separate statements (like a line break)
print                 # Print..
(                     # This is in 2.7, not 3, where print is a
                       # statement, not function
  "|"                 # Any character works here
  *24                 # Multiply said character by 24
  *n                  # Multiply resulting string by n
[:-1]                 # Remove one character due to the line break
                       # automatically created by print.

Python 2.7, 20 - 25 = -5.

If input means a variable, and you don't count n=2; as part of the program:

Simply change 24 to 20:


  • 1
    \$\begingroup\$ It's standard for input to mean STDIN or a function argument. \$\endgroup\$ – lirtosiast Oct 27 '15 at 14:46

Burlesque - 7 Bytes

blsq ) '*14.*Q

It just prints 14 asteriks, while the length of the program is 7 bytes. As for the bonus:


is 12 bytes long and prints 12*n (number provided on STDIN) asteriks.

  • \$\begingroup\$ Does your bonus version have a default value? \$\endgroup\$ – Titus Jan 27 '17 at 6:32
  • \$\begingroup\$ No. ri just converts a string to integer. \$\endgroup\$ – mroman Jan 29 '17 at 15:50

Minkolang 0.9, 11-25 = -14 bytes

This language was created after this challenge, but not for it.


Try it here.


This takes an integer from input, pushing a 2 on the stack if it's -1 (i.e., the input is empty). Then I use the clever quine trick: the " pushes the whole program (except the ") onto the stack. To make up for the ", I duplicate the top of stack with d. This is printed out n or 2 times and then the program stops. In the case where there is no input, there is indeed a -1 on the stack. However, Minkolang outputs nothing for negative numbers, so it does not add anything.


Perl 6, 3 points

say 'a'x 21 # 11
# say adds a newline
print 'a'x 28*(@*ARGS[0]//2)
# 28 - 25 = 3

Sass, 30 bytes

codegolf is absolutely awesome

if you try to compile this with sass the result is the following error

Invalid CSS after "...olutely awesome": expected "{", was "" 
/* 60 bytes */
  • \$\begingroup\$ I get invalid top-level expression on line 1 at column 1, but I also don't think this is a language as it's not turing-complete and it only compiles to CSS. \$\endgroup\$ – cat Dec 16 '15 at 13:04
  • \$\begingroup\$ @cat I'm pretty sure I could implement /// in Sass using just string manipulation and a while loop, and /// is turing complete. \$\endgroup\$ – Sparr Dec 17 '15 at 10:05
  • \$\begingroup\$ @Sparr fair enough \$\endgroup\$ – cat Dec 17 '15 at 11:57

PlatyPar, 1 byte


# starts a number, but since no number is found after it, it is substituted with 59. Here's a "real" answer:


Prints the result of 7^7, or 823543, which is of length 6.

Try it online!


Z80 machine code, 16 bytes

3E 1F 0E 02 1E 2A F5 CD 05 00 F1 3D F2 02 01 C7

This was made on an Osborne Executive running CP/M version 3.0 using SID. Here is a disassembly (with comments following # characters for readability)

MVI A,1F     # Set register A equal to 0x1F (iterations-1)
MVI C,2      # Write is BDOS call 2 (CP/M's system calls)
MVI E,2a     # I'm writing '*' as output. Its ASCII value is 0x2a
PUSH PSW     # Push operates on register pairs. This pair contains A.
CALL 5       # Do the BDOS call (which destroys some registers)
POP PSW      # But we can get A back from the stack.
DCR A        # Decrement the loop counter
JP 102       # If last result is non-negative, go to address 0x102
RST 0        # Otherwise, exit

All programs are loaded at a fixed address of 0x100, so the jump to 0x102 is well-defined. After running this, CP/M wants to print a newline character. If we count that as output from the program, change the second byte from 1F to 1E.


Fuzzy Octo Guacamole, 8 bytes


Also could use:

8  ![o;]



But that is cooler.

Prints 8 "8"s and 8 newlines, including a trailing one.


4: Push 4 to the stack.

2: Push 2 to the stack.

*: Pop and multiply the top 2 items on the stack and push the result (8)

!: Set the loop counter to the top. Is now 8.

[: Start a loop that lasts 'loopcounter' (8) iterations.

o: Peek at the top of the stack and push it to the temp variable.

;: Print the temp var.

]: End the loop.


Pylongolf, 2 bytes


. - Reset the stack
; - Debugally print both the stack and the variables.

The interpreter I use prints debugally by converting an 2 arrays into a string which has that string begin with [ and end with ] which prints:


Lua, 35 - 25 = 10 bytes

Takes input from the command line, which is in the varargs.

print(("n"):rep(35*(...or 2)-1))
  • \$\begingroup\$ You can shave off 3 bytes with print(("n"):rep(35*(...or 2)-1)) \$\endgroup\$ – Katenkyo Mar 30 '16 at 9:55

Your Answer

