# The Challenge

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

# Rules

• 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.

# Bonus

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.

# Restrictions

• 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


where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes


If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

# Perl, 43 + 2 (-p flag) = 45 bytes


You can also make the language name a link which will then show up in the leaderboard snippet:

# [><>](http://esolangs.org/wiki/Fish), 121 bytes


var QUESTION_ID=59436,OVERRIDE_USER=41505;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\-?\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• For the bonus, does the output have to be exactly n * program length bytes, or is that a minimum? – xnor Oct 2 '15 at 23:19
• It has to be exact – Daniel M. Oct 2 '15 at 23:20
• Looks like the code snippet has to be modified to handle negative scores. – El'endia Starman Oct 2 '15 at 23:49
• 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. – xnor Oct 2 '15 at 23:58
• 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. – xnor Oct 2 '15 at 23:59

class P{static void Main(){System.Console.Write($"{1,124}");}}  Will print 123 spaces followed by 1. • How does this work? – LegionMammal978 Dec 29 '15 at 14:20 • @LegionMammal978 in C# 6, @"{1,124}" is the equivalent of string.Format("{0,124}", 1) which means format the number 1 to a string with a minimum length of 124. It uses spaces to pad the value to the minimum length. See composite formatting. – Lucas Trzesniewski Dec 29 '15 at 14:45 # Ruby, 22 bytes - 25 bytes = -3 bytes c=->n=2{p ?d*21*n} c[]  The reason the value shows up as 21 bytes in the code itself is that the quotation marks are printed, effectively reducing the number of bytes I need to print by 2 (left paren and right paren). # ><>, (15 + 3) - 25 = -7 2}f*:?!;1n1-30.  Like torcado's answer, but a one-liner. Takes input via the -v flag, e.g. py -3 fish.py double.fish -v 5  and outputs 15*<input> ones. # ><>, 5 bytes "nn#;  Here's a version without any bonuses. Outputs 5935110110. # Ruby, 5 bytes p 1e6  Outputs 1000000.0 and a newline, which is 10 bytes in summary # GolfScript, 11 - 25 = -14 bytes ~2]0=11*(n*  Given n, outputs n times as many newlines as the length of the code in bytes (= 11). Given no (i.e. empty) input, outputs 22 newlines. The implementation is very straightforward: • ~ evals the input, • 2]0= replaces an empty input with 2, • 11* multiplies the input number with 11 (the length of the program), • ( decrements the number by 1 (to account for the automatically inserted trailing newline), and • n* repeats a newline the given number of times. # Brainfuck, 25 bytes Prints 50 characters, most of which are control characters. +++++++[>+++++++<-]>+[.-]  # Powershell, -10 "a"*15*$args[0]


# Powershell, 2

This answer without the bonus is probably golfier though

$?  Outputs; True  • @TimmyD does the automatic Newline added after printing count as a character? If so that doesn't work (since you end up at 2n+1). Can use param($b=2)'1'*(24*$b-2) for -1 – Jonathan Leech-Pepin Oct 7 '15 at 15:11 • @JonathanLeech-Pepin No - that won't work, either, for the same reason. See my corrected answer – AdmBorkBork Oct 7 '15 at 15:14 • @TimmyD Actually with -2 at the end of the multiplier it does. According to ISE @{1=23;2=47;3=71}. 24 characters in the function so that works when adding the newline. – Jonathan Leech-Pepin Oct 7 '15 at 15:26 • @JonathanLeech-Pepin Let's continue this discussion in chat – AdmBorkBork Oct 7 '15 at 16:21 • Also, if given no input, it should default to 2. – LegionMammal978 Dec 29 '15 at 14:08 # Sed, 40 - bonus = 15 s/^$/11/
s/.*/&&&&&/
s//&&&&&&&&/
s/.//


There's no final newline. Input is in unary, as you'd expect for sed.

We begin by defaulting the input to two. Then we multiply it by 5 and then by 8 for a total multiplication of 40. Our output includes a newline, so we must subtract one before it's printed.

# Test results

$for i in '' 1 11 111 1111; do sed -e 's/^$/11/;s/.*/&&&&&/;s//&&&&&&&&/;s/.//' <<<"$i" | wc -c; done 80 40 80 120 160  • It took a bit of trial and error to settle on 8*5 for 40; I had 5*3*3 and 7*3*2 as a couple of early attempts. – Toby Speight Oct 6 '15 at 10:51 # Python 3, 30 - 25 = 5 print(int(input()or 2)*30*"X")  It expects input on standard input, an empty input is treated the same as 2. If we can use the REPL, rather than running as a script, you can remove the print call, to save 7 bytes and bring our score down to -2: >>> int(input()or 2)*21*"X" 1 'XXXXXXXXXXXXXXXXXXXXX'  (Note that we multiply by 21, rather than 23 because of the quotation marks that appear in the string's repr.) A Python 2 version of the same code can be written for three extra bytes (we need to add raw_ to the input, but can replace the pair of parentheses around print's arguments with a single space): print int(raw_input()or 2)*33*"X"  # C#, 77 bytes 102 bytes - 25 bonus class c{static void Main(string[]a)=>System.Console.Write(new string('x',102*int.Parse(a[0]??"2")));}  Creates a string of the specified length, defaulting to 2. • @ThomasKwa: fixed it by providing a different solution. – Thomas Weller Oct 7 '15 at 20:50 # APL, -8 bytes '*'⍴⍨17×{0::2⋄⎕}⍬  Explanation: • {0::2⋄⎕}⍬: Try to read a number from the keyboard. If the user entered a valid number, return it; if not, return 2. • 17×: multiply it by 17 (the length of the code) • '*'⍴⍨: output that many asterisks. # Go, 59 Bytes package main import"fmt" func main(){fmt.Printf("%118d",0)}  Prints 0 formatted with padding ### Here is a version with argument (145-25 Bytes): package main import("os" "fmt") func main(){i:=2 if len(os.Args)>1{fmt.Sscanf(os.Args[1],"%d",&i)} fmt.Printf("%"+fmt.Sprintf("%d",i*145)+"d",i)}  • As has been mentioned in a suggested edit: You should output double length than the one of the code, not the exact length of the code. – daniero Oct 10 '15 at 13:04 # Hassium, 55 Bytes use Math;func main(){ for(x=0;x<7;x++)print(Math.pi); }  Output: 3.141592653589793.141592653589793.141592653589793.141592653589793.141592653589793.141592653589793.14159265358979  Run and see online here • I thought extra whitespaces are not allowed? – Leaky Nun Mar 30 '16 at 9:59 # Simplex v.0.5, 22 - 25 = -3 bytes i?[{u(' R)22vM}ug#]2O3 i ~~ take input as number ?[ ] ~~ do inside if byte is nonzero { } ~~ loop inside until zero byte met u v ~~ up/down strip traversal ( )22 ~~ repeats the inner 22 times '@R ~~ pushes an @ and goes right ug ~~ goes to the string strip and clears the strip # ~~ cease! 2 ~~ sets the current byte to two (default N) O3 ~~ goes to the third byte in the source code  Essentially, for each pass of an integer N (input), the string @@@@@@@@@@@@@@@@@@@@@@ is printed once, i.e., N*"@@@@@@@@@@@@@@@@@@@@@@". Since the (...) is a preproccesed command, variable inputs cannot be handled. If they could, then I might shorten the code to something like ('@R)ig whilst handling the special cases. Wouldn't that be something? # Mouse-2002, 32 - 25 = 7 bytes A quine is not possible in Mouse, unfortunately, else I would have gone that way. ?&DUP 0=[1]32*y:(y.x.>^1!x.1+x:)  Explained: ? &DUP ~ get some input; dup it 0 = ~ if 0 [ ~ then 2 ~ push 2 instead ] ~ fi 32 * y: ~ push 32* and assign into y ( ~ while(true) y. x. > ^ ~ cmp 1 ! ~ print a 1 x. 1 + x: ~ increment x ) ~ endwhile$             ~ (implicit) end prog


Note: This answer did not work when the question was asked, so it is not a competitive solution.

# Pyth, 6 - 25 = -19 bytes

mb.xE2


Demonstration

First, we attempt to take STDIN input and evaluate it. It this throws an error, we use 2 instead. Then, we make a list of that many newline characters. Newline characters take 4 characters to represent ('\n') and there are 2 bytes of list overhead ([] or ,) per element, so it comes out to exactly 6 times longer than the above number.

# Perl, 11 bytes

print"J"x22


Using the lovely x operator, prints 22 Js. I may be able to find a shorter answer.

# Python 2, 11-1-6 -11 bytes

'M'*input()*14


Prints 14 * input Ms. Requires a REPL environment.

There may be a way to make it shorter, but at this point I doubt it.

Changes

• Saved 5 bytes by not using int().
• Saves 5 more bytes thanks to @cat and using a REPL environment.
• the question doesn't say assuming a REPL environment is disallowed, so 'M'*input()*14 is shorter for 14 == -11 – cat Dec 17 '15 at 16:29
• @cat Thanks, I'll add that in now. – ASCIIThenANSI Dec 17 '15 at 16:42
• If no input is provided, you must default to 2. This does not. – isaacg Mar 30 '16 at 1:54

# MATLAB, 5 bytes

a=123


Which displays

a =
123


By my count that is 10 bytes of output if you include the new-line as 1 byte.

# Binary-Encoded Golfical, 13+1 (-x flag)=14 bytes

Noncompeting, language postdates the question.

Hexdump:

00 90 01 00 09 17 17 17 17 17 17 17 1D


This encoding can be converted back into the original graphical representation using the included Encoder utility, or run directly by adding the x flag.

Original image:

Magnified 64x, with color labels:

Explanation: Stores 9, prints it seven times (with a newline each time), then turns around and prints it seven more times.

# Mumps, 31 - 25 = 6 bytes

My submission was supposed to be unique (but I hadn't checked all of the answers yet) in that the basic "Assume 2x" code and the bonus-enabled code would work out to be the same length!

Basic code:

F J=1:1:28 W 1


Which is 14 bytes.

Here's the initial bonus-enabled code that takes input, anything that equates to '0' including any non-numeric input assumes 2, then outputs the correct number of output characters. This version is 39 bytes not including the bonus.

R I S:+I=0 I=2 F I=1:1:I F J=1:1:39 W 1


Calculating the bonus 39-25=14 bytes as well!

Too bad (for my narrative) that I looked it over and came up with a shorter version of the bonus code:

R I S:+I=0 I=2 F I=1:1:I*31 W 1


This is only 31 bytes long, so 31-25=6 bytes total, and the header reflects this.

## Mathematica, 9 bytes

Echo[16!]


If I am correct, this should output:

>> 20922789888000


with a trailing newline.

# Gogh, 3 bytes

6GJ


You can run it like this:

./gogh o '6GJ'


Or without implicit output (4 bytes):

8GJ¡


You can run this using:

./gogh "" "8GJ¡"


The inverted exclamation point outputs the TOS.

### Explanation

6    “ Push the integer literal 6 ”
G    “ Push a range (0, TOS]      ”
J    “ Join the TOS               ”


# Python 2, 11 bytes

print0*21


This outputs 21 zeroes and a newline.

000000000000000000000

From the Python 2 documentation:

A '\n' character is written at the end, unless the print statement ends with a comma.

# Cubix, 15 bytes

Non competing due to language age.

While having some fun with @ETHproductions language, I thought this would be interesting. It turned out a little longer than I thought it would and I'm sure it can be improved.

(.O.NU.\!@O$..u  This maps to a cube with edge length 2  ( . O . N U . \ ! @ O$
. . u . . . . .
. .
. .


Outputs

109998887776665554443332221110


N push 10 to the stack
U turn left moved forward turn left
O output number of TOS
$ skip a no op ( decrement TOS, followed by a number of no ops u turn right, move forward and turn right, more no ops O output number of TOS, more no ops \ reflect to the east ! jump end program @ if truthy O output number of TOS $ skip N at start of program

# Lua, 20 bytes (bonus: 11 bytes)

Program:

print(("a"):rep(40))


Output:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa


(Change 40 to 39 if newline is counted)

Bonus:

print(("a"):rep(36*(io.read()or 2)))


(If newline is counted, use print(("a"):rep(38*(io.read()or 2)-1)) [13 bytes] instead.)

• Welcome to PPCG! Usually, our community does not like storing input in variables beforehand. It would be better accepted to read from STDIN. – GamrCorps Mar 30 '16 at 3:47

(\/)a:*::**S


Outputs

(\/)(\/)(\/)(\/)(\/)(\/)


Try It Online

Explanation

(\/)            # push \/ to the stack        : \/
a           # add brackets to TOS         : (\/)
:*         # duplicate the TOS and join. : (\/)(\/)
::       # duplicate a couple of times : (\/)(\/)<>(\/)(\/)<>(\/)(\/)
**     # join stack items            : (\/)(\/)(\/)(\/)(\/)(\/)
S    # output TOS


# Tellurium, 10 bytes

µa~Åm16.


Outputs a 16 times. Simple enough.

More detailed explanation:

µ         Begins reading a string
a
~         Stops reading a string and stores it in the selected cell
Å         Command set 2
m         Print the cell's value n times
16
.


There might be a shorter version using Åw but I'm too tired to do that :P

# Java, 85

class A{public static void main(String[]s){for(A a:new A[170])System.out.println();}}


## Perl5, 11 bytes

x is string repetition operator

print 1x22

• That's only 10 bytes, and you can use 'say' to cut down on two more (run with -M5.010 flag which is free) – Gabriel Benamy Oct 23 '16 at 18:44