85
\$\begingroup\$

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.

Leaderboards

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

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

# 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>

\$\endgroup\$
  • 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

5
\$\begingroup\$

TI-BASIC, 1 byte

0

Output:

0    ;there is a newline; counts as char

Thanks to Thomas Kwa for his spectacular observation. The i/o looks as thus:

0
               0   ;right-aligned, but newline is part of output.
\$\endgroup\$
  • \$\begingroup\$ I think the newline counts as part of the output. \$\endgroup\$ – lirtosiast Oct 4 '15 at 17:53
  • \$\begingroup\$ @ThomasKwa What newline? You mean the "enter" key? \$\endgroup\$ – Conor O'Brien Oct 4 '15 at 18:18
  • \$\begingroup\$ No, the newline printed automatically after every program is executed. \$\endgroup\$ – lirtosiast Oct 4 '15 at 18:32
  • \$\begingroup\$ Oh. So change it to ᴇ3? \$\endgroup\$ – Conor O'Brien Oct 4 '15 at 18:36
  • 1
    \$\begingroup\$ Yes, but it can just be 0 as I commented on the other TI-BASIC answer by Deusovi. \$\endgroup\$ – lirtosiast Oct 4 '15 at 18:39
5
\$\begingroup\$

Shakespeare Programming Language, 216 192 191 bytes

Twice the source.Ajax,.Puck,.Act I:.Scene I:.[Exeunt][Enter Ajax and Puck]Ajax:Open heart!You big big big big big big big cat!Puck:You is the sum ofyou a cat!Be you worse I?If solet us Act I!

Try it online!

Prints a 0 followed by 128 128s.

\$\endgroup\$
4
\$\begingroup\$

Ruby, 24 - 25 = -1

$><<?x*24*(gets||2).to_i
\$\endgroup\$
4
\$\begingroup\$

Self-modifying Brainfuck, 31 - 25 = 6 bytes

Checking for no input is a hassle...

>,>+<[>-]>[<++>->]<<[<<[.<]>>-]

Explanation:

See the If(x==0) algorithm I used (the one by Ben-Arba).

>,                      Take a byte of input x
>+<[>-]>[<++>->]<<      If x == 0 (no input), x++ (add 2 :D)
[<<[.<]>>-]             Print the program's source code in reverse x times

Without the bonus (10 bytes):

<[.<]>[.>]

Wishful thinking:

If we didn't have to default the input to two (13 - 25 = -12 bytes):

>,[<<[.<]>>-]
\$\endgroup\$
4
\$\begingroup\$

Bubblegum, 1 byte

Ä

prints

!#

Test run

$ echo -en '\xc4' > double.bg
$ bubblegum double.bg 
!#
\$\endgroup\$
  • \$\begingroup\$ That's two or three bytes, one character (depends on encoding). Do bytes == characters here? \$\endgroup\$ – Nateowami Oct 5 '15 at 10:23
  • \$\begingroup\$ I/O is raw in Bubblegum. It only knows bytes, not characters. \$\endgroup\$ – Dennis Oct 5 '15 at 13:33
  • 1
    \$\begingroup\$ Yeah, that's what I was thinking, but... how is Ä one byte in any sense? After all, if input is raw, that's two bytes, that just happen to be one character. Am I missing something? How can Ä possibly be "1 byte"? \$\endgroup\$ – Nateowami Oct 6 '15 at 9:12
  • 2
    \$\begingroup\$ @Nateowami in ISO-8859-1, for example, Ä is a single byte, 0xC4. \$\endgroup\$ – primo Oct 6 '15 at 11:34
  • \$\begingroup\$ @primo Thanks, I wouldn't have guessed. Perhaps the encoding should be specified though, because using the reference implementation I get -M?). Likely the encoding got changed when the post was submitted (or else when I used echo Ä > file.txt and gedit). \$\endgroup\$ – Nateowami Oct 6 '15 at 11:57
4
\$\begingroup\$

Python 2.7, 26 24 - 25 = -1 byte

def s(c=2):print'A'*24*c

24 characters long, prints twice its length on no input:

>>> s()
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

prints n*length for any other input:

>>> s(1)
AAAAAAAAAAAAAAAAAAAAAAAA
>>> s(3)
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
\$\endgroup\$
4
\$\begingroup\$

Java 8, 82 Bytes

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

Prints out 164 empty lines.

\$\endgroup\$
4
\$\begingroup\$

C, 36 bytes

main(a){for(a=4;a--;)puts(puts);}//!

Really hacky stuff here. The implementation of puts on my machine (gcc 6.3) has 16 bytes before it hits a null, and adds a newline and SOH (18 bytes total). Run four times, and it's 72 (or 0x48) chars. I padded mine with a 3-char comment to fit that. Most of the chars are unreadable, so here's a hexdump of the output.

0000000 5541 5441 8949 55fc 4853 ec83 e808 76ae
0000010 0a01 5541 5441 8949 55fc 4853 ec83 e808
0000020 76ae 0a01 5541 5441 8949 55fc 4853 ec83
0000030 e808 76ae 0a01 5541 5441 8949 55fc 4853
0000040 ec83 e808 76ae 0a01
0000048
\$\endgroup\$
3
\$\begingroup\$

Mouse, 21 bytes

1I:(I.43<^9!1I.+I:)$

Ungolfed:

1 I:                  ~ Begin a loop index at 1
( I. 43 < ^           ~ While I < 43...
  9 !                 ~ Print 9 to STDOUT
  1 I. + I:           ~ Increment I
)$
\$\endgroup\$
  • \$\begingroup\$ I didn't know others knew Mouse! you csn shave bytes by not initialisingI, because its value will start at zero, and making it 42 instead. \$\endgroup\$ – cat Dec 16 '15 at 12:17
  • \$\begingroup\$ eg. (i.31<^9!i.1+i:) is 16 bytes \$\endgroup\$ – cat Dec 16 '15 at 13:34
3
\$\begingroup\$

q, 10 3 bytes

3#0

Outputs 6 bytes: "0 0 0\n".

\$\endgroup\$
  • 1
    \$\begingroup\$ If I understand the challenge correctly, an 8-byte long program should produce 16 bytes of output... \$\endgroup\$ – undergroundmonorail Oct 3 '15 at 5:46
  • \$\begingroup\$ Right. I should have read past the title. I've updated my answer. \$\endgroup\$ – Alexander Belopolsky Oct 3 '15 at 6:19
3
\$\begingroup\$

JavaScript (ES6), 24 30 - 25 = 5 bytes

alert('s'.repeat(30*prompt()))
\$\endgroup\$
  • \$\begingroup\$ The question requires a full program. Your code will only work inside a REPL environment. \$\endgroup\$ – Dennis Oct 4 '15 at 13:32
  • \$\begingroup\$ @Dennis, there is no other way for JavaScript to receive input, and using prompt is standard practice in other golfing challenges where input is required. \$\endgroup\$ – Patrick Roberts Oct 4 '15 at 14:19
  • \$\begingroup\$ @PatrickRoberts If you use prompt to input, then you should use something like alert to output. \$\endgroup\$ – Doorknob Oct 4 '15 at 14:27
  • \$\begingroup\$ prompt isn't the issue. This will produce no output outside a REPL environment. \$\endgroup\$ – Dennis Oct 4 '15 at 14:59
  • \$\begingroup\$ I updated the answer to alert the value, also removing the unnecessary unary plus operator since the multiplication will coerce the value to a number. \$\endgroup\$ – Patrick Roberts Oct 4 '15 at 16:22
3
\$\begingroup\$

C, 23 (without bonus)

main(){printf("%46d");}

Outputs an uninitialized value, padded by spaces to 46 bytes. Trying to do it with a bonus, I arrived to a tie. I don't know whether it's unfortunate or cool.

C, 23 (with bonus)

main(x){printf("%*d",(~scanf("%d",&x)?x:2)*48);}

The code has 48 bytes. I use bit-complement ~ to check whether scanf returned -1.

\$\endgroup\$
3
\$\begingroup\$

Python 2, 11 bytes

print 9**21

displays 109418989131512359209\n (22 chars)

\$\endgroup\$
3
\$\begingroup\$

Funciton, 78 bytes

Not very advanced. Just output 156 As. Of course you can change 65 to any two-digit ASCII code. If non-printable characters are allowed as well, you could shorten it by 6 bytes by outputting character #1 144 times.

╔═══╗┌─╖╔══╗
║156╟┤…╟╢65║
╚═══╝╘╤╝╚══╝
\$\endgroup\$
  • \$\begingroup\$ You could use the TAB character, 9. \$\endgroup\$ – Titus Jan 27 '17 at 6:36
3
\$\begingroup\$

Vitsy, 14 11 - 25 = -14 Bytes

Note: This language was made after this question was asked, but it was not created for this task.

2a{b*\[DO];

I'm pretty sure this can be golfed down a little more, but here you go:

2a{b*\[DO];
2              Push 2 to the stack as the backup value - if input is pushed, then it will already exist in the stack.
 a             Push "\n" (the literal) to the stack as an integer - this will be our output.
  {            Rotate the stack to the left
   b*          Multiply the top value (used to be the back-most (2 or input) value) by 11.
     \[..]     Repeat as many times as the top item of the stack specifies for all instructions within []
       DO      Duplicate the top value, then output it.
          ;    End execution.
\$\endgroup\$
3
\$\begingroup\$

Common Lisp REPL, 9

(write -)

- is a variable that holds the currently evaluating expression in the REPL, while write returns whatever it writes. So it writes (write -) then returns "(write -)" which is printed by the REPL without the quotes. (If this was done in an REL instead of an REPL, then it'd be a quine instead.)

\$\endgroup\$
3
\$\begingroup\$

Python, 15 bytes

print 'aaaaa'*6

Prints:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Which is 30 bytes.

\$\endgroup\$
  • 1
    \$\begingroup\$ There are already two shorter Python 2 answers. \$\endgroup\$ – lirtosiast Oct 27 '15 at 14:50
  • 2
    \$\begingroup\$ @ThomasKwa well I'm sorry I didn't read through all 110 answers </sarcasm> \$\endgroup\$ – TheDoctor Oct 27 '15 at 14:52
  • 6
    \$\begingroup\$ There's a stack snippet at the top. All you need to do is click two buttons and scroll down to Python. Both of those answers were on the first page anyway. \$\endgroup\$ – lirtosiast Oct 27 '15 at 14:58
  • \$\begingroup\$ You could use print'a'*11 to save 4 bytes. \$\endgroup\$ – ASCIIThenANSI Dec 17 '15 at 16:00
  • 1
    \$\begingroup\$ @ASCIIThenANSI print'a'*22. The output needs to be twice the length of your code. \$\endgroup\$ – Erik the Outgolfer Sep 22 '16 at 14:27
3
\$\begingroup\$

J, 6 5 3 2 bytes (bonus: -11 bytes) (try it online)

Program:

%4

Output:

0.25

Explanation: The reciprocal of 4.

Bonus:

10,1$~_1+7*]/2

Testcases:

10,1$~_1+7*]/2    :10 1 1 1 1 1 1 1 1 1 1 1 1 1
10,1$~_1+7*]/2 2  :10 1 1 1 1 1 1 1 1 1 1 1 1 1
10,1$~_1+7*]/2 3  :10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Explanation:

10,               NB. prepend 10 to
   1$~            NB. the "~" reverses the arguments.
                  NB.    e.g. 1 $~ 5 becomes 5 $ 1.
                  NB.    5 $ 1 means create an array of size 5,
                  NB.    using the number 1. The number is
                  NB.    recycled because there is not enough number.
                  NB.    For example, 5$1 2 3 would produce 1 2 3 1 2.
      _1+         NB. add negative one to
         7*       NB. seven multiplied by
           ]/2    NB. if the input is 5, then this part
                  NB.    becomes 2]5, which evaluates to 5.
                  NB.    if there is no input, then this
                  NB.    part is only 2.

3-byte attempt:

7^7

Output:

823543

Explanation: 7 raised to the power 7.

Notes: Looks like I am not the first one to discover this.


5-byte attempt:

Program:

*:i.5

Output:

0 1 4 9 16

Explanation: *: means square. i.5 means generate a list from 0 to 4


6-byte attempt:

Program:

10,5$5

Output:

10 5 5 5 5 5

Explanation:

5$5 means create an array of size 5 (on the left of $), using the number 5 (on the right of $). The number is recycled because there is not enough number.

For example, 5$1 2 3 would produce 1 2 3 1 2.

\$\endgroup\$
  • \$\begingroup\$ Looks like I am not the first one to discover <code>7^7</code>... never mind, I still discovered it myself. \$\endgroup\$ – Leaky Nun Mar 30 '16 at 2:15
3
\$\begingroup\$

Desmos, 3 bytes

9^6

Equals 531441

\$\endgroup\$
  • \$\begingroup\$ I'm not sure desmos is considered a language, though it is pretty awesome. \$\endgroup\$ – Daniel M. Jul 3 '16 at 22:54
  • 1
    \$\begingroup\$ Desmos is technically a programming language since you can program things with it. \$\endgroup\$ – weatherman115 Jul 4 '16 at 1:22
  • \$\begingroup\$ Desmos satisfies our requirements. \$\endgroup\$ – Mego Jul 4 '16 at 5:21
3
\$\begingroup\$

05AB1E, 6 - 25 = -19 bytes (noncompeting)

VžOY×?

Try it online!

VžMY×?  Argument n
V       Assign n to Y, if n is empty Y defaults to 2
 žO     Push 'aeiouy' to stack (has same length as program)
   Y×   Repeat the string Y times
     ?  Print top of stack without newline
\$\endgroup\$
  • \$\begingroup\$ You have been outgolfed. \$\endgroup\$ – Oliver Ni Jun 3 '17 at 16:05
  • \$\begingroup\$ @OliverNi Does the input default to 2 if not given? \$\endgroup\$ – kalsowerus Jun 3 '17 at 16:09
  • \$\begingroup\$ Oh. I'll fix that. \$\endgroup\$ – Oliver Ni Jun 3 '17 at 16:18
3
\$\begingroup\$

Bash, 5 bytes

seq 5

Output (with a newline char on the end of each gives 10 bytes)...

1
2
3
4
5

\$\endgroup\$
3
\$\begingroup\$

Whitespace, 38 36 bytes

SSTTTSTTNNSSNSNSTNSTSSSTNTSSSSNSNTTN

Try it online!

Prints "-27-26-25-24-23-22-21-20-19-18-17-16-15-14-13-12-11-10-9-8-7-6-5-4-3-2-1". Whitespace doesn't have optional input so I can't go for the bonus.

\$\endgroup\$
  • 1
    \$\begingroup\$ Could you print -1 to shorten it? \$\endgroup\$ – Jo King May 21 '18 at 22:50
  • \$\begingroup\$ @JoKing managed to save off 2 bytes with an idea I got from your suggestion. \$\endgroup\$ – CensoredUsername May 21 '18 at 23:02
3
\$\begingroup\$

PowerShell, 3 bytes

1e4

Try it online!

PowerShell, 1 byte

Thanks to @mazzy for pointing this one out!

1

Try it online!

Both programs' outputs includes a trailing newline!

\$\endgroup\$
  • 3
    \$\begingroup\$ You could to try 1. Output includes a trailing newline! \$\endgroup\$ – mazzy Dec 9 '18 at 7:03
3
\$\begingroup\$

Perl 6, 17 - 25 = -8 points

print e x(get||2)

Try it online!

Prints the builtin constant e (\$2.718281828459045\$) either input or 2 times. Luckily, the precision of the constant is 17 bytes long, exactly the same as my code length.

Explanation:

print              # Print without newline
      e            # The constant e (2.718281828459045)
        x(      )  # String multiplied by
          get      # The input
             ||2   # Or two if the input does not exist
\$\endgroup\$
3
\$\begingroup\$

Deadfish~, 5 bytes

You expected a worthwhile submission, but it was ME:

{dio}

Try it online!

Prints the number "1" ten times.

\$\endgroup\$
2
\$\begingroup\$

Ruby, 6 bytes

p ?a*9

Prints "aaaaaaaaa" (including the quotes) and a newline.

\$\endgroup\$
2
\$\begingroup\$

awk, 29 - 25 = 4 bytes

{printf"%0"($0?$0:2)*29"d",0}

Prints the wanted number of zeros.

\$\endgroup\$
2
\$\begingroup\$

JavaScript (ES6), 23 bytes - 25 = -2

(n=2)=>'x'.repeat(23*n)

Just for fun here's a quine version with a score of 27 bytes -25 =2

a=(n=2)=>`a=${a}`.repeat(n)
\$\endgroup\$
  • 1
    \$\begingroup\$ Does this really write to standard output? \$\endgroup\$ – immibis Oct 3 '15 at 0:26
  • \$\begingroup\$ It's a function return, using fat arrow notation. \$\endgroup\$ – MayorMonty Oct 3 '15 at 2:25
  • 3
    \$\begingroup\$ The spec requires a full program... \$\endgroup\$ – John Dvorak Oct 3 '15 at 16:39
  • 2
    \$\begingroup\$ Running this program just gives me a function. Its output is a function that the length isn't double, nor does it take standard input. \$\endgroup\$ – Unihedron Oct 4 '15 at 12:57
  • \$\begingroup\$ Writing functions that return the required result, as well as taking input from function arguments, is allowed. \$\endgroup\$ – ivzem May 24 '17 at 12:50
2
\$\begingroup\$

JavaScript (ES6), 50-25=25

a=prompt();alert("0".repeat(48*(isNaN(a|0)?2:+a)))
\$\endgroup\$
2
\$\begingroup\$

PHP 7, 9 Bytes

<?=str_repeat(1,($argv[1]??2)*34);

Uses the short opening tag with echo <?= and the null coalesce operator ?? which falls back to 2 if $argv[1] is not set, without throwing an error.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.