Double it your wayI double the source, you double the output!Third time the charmDouble-time is not double timePrint out the first N characters of your codeDouble-slit QuineBeatles Songs and HexagonsHow did I end up with this FizzBuzz?I double the source, you double the output!Double-time is not double timeThird time the charmunRSA: solve the private keyLongest Repeating Subsequence of a Single Digit

Have there been any countries that voted themselves out of existence?

Why don't I get the correct limit of a sequence, regardless of how I arrange it (the sequence), while following the rules for solving limits?

Sol Ⅲ = Earth: What is the origin of this planetary naming scheme?

Writing a worded mathematical expression

Is there a standard terminology for female equivalents of terms such as 'Kingdom' and if so, what are the most common terms?

Is Salesforce Classic being deprecated?

Seized engine due to being run without oil

Are programming languages necessary/useful for operations research practitioner?

How can I protect myself in case of a human attack like the murders of the hikers Jespersen and Ueland in Morocco?

Are there any space probes or landers which regained communication after being lost?

Creating a Master Image to roll out to 30 new Machines Licensing Issues

Defining a function which returns a function pointer which also returns a function pointer without typedefs

A Little Riddle

Why is the T-1000 humanoid?

Why did they ever make smaller than full-frame sensors?

Is it possible to PIVOT on a LIKE statement

Gas pipes - why does gas burn "outwards?"

Relevance of the Resurrection

Can a new chain significantly improve the riding experience? If yes - what else can?

What does "synoptic" mean in avionics?

Should I leave the first authourship of our paper to the student who did the project whereas I solved it?

Exact Brexit date and consequences

Kingdom Map and Travel Pace

How seriously should I take a CBP interview where I was told I have a red flag and could only stay for 30 days?



Double it your way


I double the source, you double the output!Third time the charmDouble-time is not double timePrint out the first N characters of your codeDouble-slit QuineBeatles Songs and HexagonsHow did I end up with this FizzBuzz?I double the source, you double the output!Double-time is not double timeThird time the charmunRSA: solve the private keyLongest Repeating Subsequence of a Single Digit






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








16












$begingroup$


Double it your way



There have been a couple of challenges involving doubling source code: here and here. The task we have here is a bit harder, but should be doable in almost every language.



In this challenge, you will take in an arbitrary positive integer. Your program must output that integer doubled.
When your source code is doubled, it will take in a positive integer, and output it squared.



How is your source code doubled? Well, you can have it your way.
That is to say, you can split your source code up into strings of bytes or characters (or tokens in tokenized langs) of any equal length you want, and repeat each chunk twice in succession.



For an initial program of ABCDEFGHIJKL, (length 12) here are all possible doubled programs:



Chunk length | Doubled source code
-------------+-------------------------
1 | AABBCCDDEEFFGGHHIIJJKKLL
2 | ABABCDCDEFEFGHGHIJIJKLKL
3 | ABCABCDEFDEFGHIGHIJKLJKL
4 | ABCDABCDEFGHEFGHIJKLIJKL
6 | ABCDEFABCDEFGHIJKLGHIJKL
12 | ABCDEFGHIJKLABCDEFGHIJKL


Note that this means programs of prime lengths can only be doubled two ways: every character doubled, or the full program is repeated twice.



Rules:



  • Code must be a full program or function.

  • Standard loopholes are forbidden.

  • Standard I/O methods are allowed.

  • All characters/bytes, including whitespace and newlines, are counted in the length of the code and contribute to chunks.

  • You may assume that the input and its square can be represented by your language's int/integer type.

  • You may not assume a trailing newline or other character.

  • Provide your chunk size in the heading after the byte count.

  • This is code-golf, so shorter programs are better! If two programs are the same length, the one which uses the smaller chunk length wins. (If you have a longer program which uses a smaller chunk length, that is worth posting too!)

  • If your program requires a second input/line, you may make no assumptions on its value. In particular, your program should work if the second input is empty, the same as the first, or a different integer. If your program does not require a second input/line, you may ignore this restriction.


Sandbox link











share|improve this question











$endgroup$









  • 2




    $begingroup$
    @Arnauld okay, I undid that. I like the smaller-chunk solutions, but I'll leave the criteria as it is.
    $endgroup$
    – GammaFunction
    11 hours ago


















16












$begingroup$


Double it your way



There have been a couple of challenges involving doubling source code: here and here. The task we have here is a bit harder, but should be doable in almost every language.



In this challenge, you will take in an arbitrary positive integer. Your program must output that integer doubled.
When your source code is doubled, it will take in a positive integer, and output it squared.



How is your source code doubled? Well, you can have it your way.
That is to say, you can split your source code up into strings of bytes or characters (or tokens in tokenized langs) of any equal length you want, and repeat each chunk twice in succession.



For an initial program of ABCDEFGHIJKL, (length 12) here are all possible doubled programs:



Chunk length | Doubled source code
-------------+-------------------------
1 | AABBCCDDEEFFGGHHIIJJKKLL
2 | ABABCDCDEFEFGHGHIJIJKLKL
3 | ABCABCDEFDEFGHIGHIJKLJKL
4 | ABCDABCDEFGHEFGHIJKLIJKL
6 | ABCDEFABCDEFGHIJKLGHIJKL
12 | ABCDEFGHIJKLABCDEFGHIJKL


Note that this means programs of prime lengths can only be doubled two ways: every character doubled, or the full program is repeated twice.



Rules:



  • Code must be a full program or function.

  • Standard loopholes are forbidden.

  • Standard I/O methods are allowed.

  • All characters/bytes, including whitespace and newlines, are counted in the length of the code and contribute to chunks.

  • You may assume that the input and its square can be represented by your language's int/integer type.

  • You may not assume a trailing newline or other character.

  • Provide your chunk size in the heading after the byte count.

  • This is code-golf, so shorter programs are better! If two programs are the same length, the one which uses the smaller chunk length wins. (If you have a longer program which uses a smaller chunk length, that is worth posting too!)

  • If your program requires a second input/line, you may make no assumptions on its value. In particular, your program should work if the second input is empty, the same as the first, or a different integer. If your program does not require a second input/line, you may ignore this restriction.


Sandbox link











share|improve this question











$endgroup$









  • 2




    $begingroup$
    @Arnauld okay, I undid that. I like the smaller-chunk solutions, but I'll leave the criteria as it is.
    $endgroup$
    – GammaFunction
    11 hours ago














16












16








16





$begingroup$


Double it your way



There have been a couple of challenges involving doubling source code: here and here. The task we have here is a bit harder, but should be doable in almost every language.



In this challenge, you will take in an arbitrary positive integer. Your program must output that integer doubled.
When your source code is doubled, it will take in a positive integer, and output it squared.



How is your source code doubled? Well, you can have it your way.
That is to say, you can split your source code up into strings of bytes or characters (or tokens in tokenized langs) of any equal length you want, and repeat each chunk twice in succession.



For an initial program of ABCDEFGHIJKL, (length 12) here are all possible doubled programs:



Chunk length | Doubled source code
-------------+-------------------------
1 | AABBCCDDEEFFGGHHIIJJKKLL
2 | ABABCDCDEFEFGHGHIJIJKLKL
3 | ABCABCDEFDEFGHIGHIJKLJKL
4 | ABCDABCDEFGHEFGHIJKLIJKL
6 | ABCDEFABCDEFGHIJKLGHIJKL
12 | ABCDEFGHIJKLABCDEFGHIJKL


Note that this means programs of prime lengths can only be doubled two ways: every character doubled, or the full program is repeated twice.



Rules:



  • Code must be a full program or function.

  • Standard loopholes are forbidden.

  • Standard I/O methods are allowed.

  • All characters/bytes, including whitespace and newlines, are counted in the length of the code and contribute to chunks.

  • You may assume that the input and its square can be represented by your language's int/integer type.

  • You may not assume a trailing newline or other character.

  • Provide your chunk size in the heading after the byte count.

  • This is code-golf, so shorter programs are better! If two programs are the same length, the one which uses the smaller chunk length wins. (If you have a longer program which uses a smaller chunk length, that is worth posting too!)

  • If your program requires a second input/line, you may make no assumptions on its value. In particular, your program should work if the second input is empty, the same as the first, or a different integer. If your program does not require a second input/line, you may ignore this restriction.


Sandbox link











share|improve this question











$endgroup$




Double it your way



There have been a couple of challenges involving doubling source code: here and here. The task we have here is a bit harder, but should be doable in almost every language.



In this challenge, you will take in an arbitrary positive integer. Your program must output that integer doubled.
When your source code is doubled, it will take in a positive integer, and output it squared.



How is your source code doubled? Well, you can have it your way.
That is to say, you can split your source code up into strings of bytes or characters (or tokens in tokenized langs) of any equal length you want, and repeat each chunk twice in succession.



For an initial program of ABCDEFGHIJKL, (length 12) here are all possible doubled programs:



Chunk length | Doubled source code
-------------+-------------------------
1 | AABBCCDDEEFFGGHHIIJJKKLL
2 | ABABCDCDEFEFGHGHIJIJKLKL
3 | ABCABCDEFDEFGHIGHIJKLJKL
4 | ABCDABCDEFGHEFGHIJKLIJKL
6 | ABCDEFABCDEFGHIJKLGHIJKL
12 | ABCDEFGHIJKLABCDEFGHIJKL


Note that this means programs of prime lengths can only be doubled two ways: every character doubled, or the full program is repeated twice.



Rules:



  • Code must be a full program or function.

  • Standard loopholes are forbidden.

  • Standard I/O methods are allowed.

  • All characters/bytes, including whitespace and newlines, are counted in the length of the code and contribute to chunks.

  • You may assume that the input and its square can be represented by your language's int/integer type.

  • You may not assume a trailing newline or other character.

  • Provide your chunk size in the heading after the byte count.

  • This is code-golf, so shorter programs are better! If two programs are the same length, the one which uses the smaller chunk length wins. (If you have a longer program which uses a smaller chunk length, that is worth posting too!)

  • If your program requires a second input/line, you may make no assumptions on its value. In particular, your program should work if the second input is empty, the same as the first, or a different integer. If your program does not require a second input/line, you may ignore this restriction.


Sandbox link








code-golf integer source-layout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 hours ago







GammaFunction

















asked 17 hours ago









GammaFunctionGammaFunction

1,4101 silver badge14 bronze badges




1,4101 silver badge14 bronze badges










  • 2




    $begingroup$
    @Arnauld okay, I undid that. I like the smaller-chunk solutions, but I'll leave the criteria as it is.
    $endgroup$
    – GammaFunction
    11 hours ago













  • 2




    $begingroup$
    @Arnauld okay, I undid that. I like the smaller-chunk solutions, but I'll leave the criteria as it is.
    $endgroup$
    – GammaFunction
    11 hours ago








2




2




$begingroup$
@Arnauld okay, I undid that. I like the smaller-chunk solutions, but I'll leave the criteria as it is.
$endgroup$
– GammaFunction
11 hours ago





$begingroup$
@Arnauld okay, I undid that. I like the smaller-chunk solutions, but I'll leave the criteria as it is.
$endgroup$
– GammaFunction
11 hours ago











17 Answers
17






active

oldest

votes


















9














$begingroup$


05AB1E, 4 bytes (chunk size 2 or 4)



·Inr


Try it online or doubled as a single 4-byte chunk or doubled as two 2-byte chunks.



· # double the implicit input
In # square the input
r # reverse the stack
# stack is now [input ** 2, input * 2]
# if we stop here, the top (input * 2) is implicitly outputted
· # double the top of the stack (giving 4 * input, not that it matters)
In # square the input
r # reverse the stack, putting the first
# stack is now [input ** 2, input * 4, input ** 2]
# input ** 2 is implicitly outputted





share|improve this answer











$endgroup$






















    8














    $begingroup$


    Perl 5, 8 bytes (chunk size 4)





    $_*=~~+2


    Try it online, or try the doubled version.



    Unary ~ is the bitwise negate, so applying it twice is a noop. Thus, the base program simply multiplies $_ (the implicit input-output variable) by 2.



    Binary ~~ is smartmatch, which returns a boolean. ~~+2~~+2 parses as (~~+2) ~~ (+2). Since 2 equals 2, this yields true (1). Thus, the doubled program first multiplies $_ by 1, then multiplies $_ by itself.






    share|improve this answer











    $endgroup$






















      7














      $begingroup$


      Befunge-98 (FBBI), 8 bytes (chunk length 2)



      ;&:#* +q


      Try it online!



      ;&;&:#:#* * +q+q


      Try it online! (doubled)



      Excluding control flow, the first program executes &:+q (input, duplicate top of stack, add, exit with return code), and the second executes &:*+q (input, duplicate top of stack, multiply, add (sums with an implicit 0), exit with return code)






      share|improve this answer











      $endgroup$






















        4














        $begingroup$


        Python 3, 32 30 28 bytes (chunk size 16 15 14)





        lambda n:bool(0)*n*n or 2*n


        Try it online!



        -4 bytes thanks to @negativeSeven



        Doubled:





        lambda n:bool(lambda n:bool(0)*n*n or 2*n0)*n*n or 2*n


        Try it online!



        The function takes advantage of the unique chunk rule of this challenge.






        share|improve this answer











        $endgroup$










        • 1




          $begingroup$
          26: TIO
          $endgroup$
          – Grimy
          7 hours ago











        • $begingroup$
          @Grimy Nice approach. I think it is different enough and deserves its own post.
          $endgroup$
          – Joel
          5 hours ago


















        3














        $begingroup$

        JavaScript (ES6),  24  22 bytes



        Despite its unusual format, this is the definition of an anonymous function, which can be either called directly or assigned to a variable.





        +(g=x=>x*x)?g:(x=>x*2)


        Try it online!



        +(g=x=>x*x)?g:(x=>x*2)+(g=x=>x*x)?g:(x=>x*2)


        Try it online doubled!



        How?



        Applying the unary + to a function is interpreted as an attempt to coerce it to a number and results in NaN. Therefore, the leading +(g=x=>x*x) is falsy in both versions.



        On the other hand, applying the binary + between 2 functions results in a string. Therefore, (x=>x*2)+(g=x=>x*x) is truthy in the doubled version.






        share|improve this answer











        $endgroup$






















          2














          $begingroup$


          Runic Enchantments, 9 bytes (chunk size 3)



          i3?:*@:+@


          Try it online!
          Try it doubled!



          The 3? skips the next 3 instructions, resulting in an (executed) i3?...:+@. When doubled it results in an executed i3?...:*@ where . represents the 3 NOP'd instructions. @ is "print entire stack and terminate."






          share|improve this answer









          $endgroup$






















            1














            $begingroup$


            Charcoal, 13 bytes



            PI×Iθ⎇υIθ²⊞υω


            Try it online! Explanation: The predefined empty list is falsey so the input is multiplied by 2. When doubled the second pass sees the empty string has been pushed to the list so it multiplies the input by itself instead. Try it online! In verbose syntax this corresponds to Multiprint(Cast(Times(Cast(q), Ternary(u, Cast(q), 2)))); Push(u, w);.






            share|improve this answer









            $endgroup$






















              1














              $begingroup$


              R, 59 bytes (chunk size 59)





              c(`*`,`^`)[[1+length(readLines())]](scan(file("stdin")),2)



              Try it online!



              Note the trailing newline. This forces scan to read from stdin rather than the source file (which is what stdin() redirects to....), and use readLines() to ignore all additional copies of the source, inspired by this answer to a similar challenge.



              This isn't particularly interesting, but doubtless something clever manipulating the chunk size will be dreamed up.






              share|improve this answer









              $endgroup$






















                1














                $begingroup$


                Japt, 7 5 bytes



                *N²jJ


                Try it | Doubled



                ² pushes 2 to the array of inputs N then j removes & returns the element at index J=-1 (i.e., the newly inserted 2) and multiplies the input by that.



                When doubled it results in J being multiplied by 2, so the element at index -2 (i.e., the input) is returned by j and used as the multiplier.






                share|improve this answer











                $endgroup$






















                  1














                  $begingroup$


                  C# (Visual C# Interactive Compiler) / Javascript, 22 bytes, chunk size 11





                  m=>/* /2*m//*/m*2


                  Try it online!






                  share|improve this answer











                  $endgroup$














                  • $begingroup$
                    Also works in JavaScript
                    $endgroup$
                    – Shaggy
                    7 hours ago


















                  1














                  $begingroup$


                  Perl 6, 8 bytes (chunk size 1)





                  * *<1 2>


                  Try it online! Try it doubled!



                  A Whatever/HyperWhatever lambda that takes a number and returns a number for the first program and a singleton list for the second program. Basically this keeps the exact same logic, except that the multiplication operator (*) is replaced by the exponential one (**).



                  The Whatever literal (confusingly also represented by a *) are doubled up to a HyperWhatever (**) which is basically the same except it maps over lists. The space is needed to separate the Whatever literal from the multiplication and is ignored when doubled up. Instead of just 2 (which would get doubled to 22) we use a list containing two elements, which evaluates to 2 in a numeric context). The <> can be doubled to a list with interpolation, and the two elements inside are doubled, but neither of those change the length of the list.






                  share|improve this answer











                  $endgroup$






















                    1














                    $begingroup$


                    Brain-Flak (BrainHack), 76 bytes, 76 byte chunks



                    (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                    Try it online!



                    Doubled (with newline for clarity)



                    (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>
                    (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                    Try it online!



                    Here is a version that uses a more complex doubling procedure. It does 5 chunks of size 15. The code here is 46 bytes however due to the required padding it is substantially longer.



                    105 bytes, 15 byte chunks



                    ( <>< <>>()([()])<><(()())><> )<> 


                    Try it online!



                    Doubled (with newlines for clarity)



                    ( ( 

                    <>< <><
                    <>>()([()])<>>()([()])
                    <><(()())><> <><(()())><>

                    )<> )<>


                    Try it online!






                    share|improve this answer











                    $endgroup$






















                      0














                      $begingroup$

                      Perl 5 (-p), 22 15 bytes



                      -7 bytes thanks to Grimy



                      $_*=$'/4||2;//;


                      TIO






                      share|improve this answer











                      $endgroup$














                      • $begingroup$
                        15: TIO
                        $endgroup$
                        – Grimy
                        15 hours ago










                      • $begingroup$
                        looking at your solution, I'd just found a 22 bytes solution
                        $endgroup$
                        – Nahuel Fouilleul
                        15 hours ago










                      • $begingroup$
                        understood, first input*=2, then by input*=input/4
                        $endgroup$
                        – Nahuel Fouilleul
                        15 hours ago










                      • $begingroup$
                        another 16 bytes (-a) $_*=/@F/?2:$_/4;
                        $endgroup$
                        – Nahuel Fouilleul
                        15 hours ago










                      • $begingroup$
                        Down to 8 (posted as a separate answer since it's very different).
                        $endgroup$
                        – Grimy
                        15 hours ago


















                      0














                      $begingroup$

                      Python 3, 56 53 bytes





                      print(eval(input()+"**2"[len(*open(__file__))%2:])) #


                      My python skills kinda suck, so can definitely be golfed.. Based on the Python answer in the "I double the source, you double the output!" challenge.



                      Chunk length 53.



                      Try it online or try it online doubled.






                      share|improve this answer











                      $endgroup$






















                        0














                        $begingroup$

                        Java 8, 62 bytes





                        n->n*(Byte.SIZE>8?n:2);/*
                        class Bytestatic int SIZE=9;/**///


                        Chunk length 62.



                        Try it online or try it online doubled.



                        Explanation:



                        n-> // Method with integer as both parameter and return-type
                        n* // The input, multiplied by:
                        (Byte.SIZE>8? // If Byte.SIZE is larger than 8:
                        n // Multiply by the input itself
                        : // Else:
                        2); // Multiply by 2
                        class Byte // Class which overwrites Byte
                        static int SIZE=9; // And sets the SIZE to 9


                        In Java, the available comments are // comment and /* comment */. Which are combined here to overwrite certain parts. See how these comments work thanks to the Java highlighting:



                        n->n*(Byte.SIZE>8?n:2);/*
                        class Bytestatic int SIZE=9;/**///

                        n->n*(Byte.SIZE>8?n:2);/*
                        class Bytestatic int SIZE=9;/**///n->n*(Byte.SIZE>8?n:2);/*
                        class Bytestatic int SIZE=9;/**///


                        The doubled program created a custom Byte class and its value SIZE=9, which overwrites the default java.lang.Byte class and its value SIZE=8.






                        share|improve this answer











                        $endgroup$






















                          0














                          $begingroup$


                          Jelly, 8 6 bytes (chunk length 3)



                          Ḥ;²3ị 


                          Try it online!



                          Doubled






                          share|improve this answer











                          $endgroup$






















                            0














                            $begingroup$


                            J, 17 bytes



                            *:@[`(+:@[)@.(=~)


                            Try it online!



                            Doubled version: Try it online!



                            In the single version, we have a single verb which uses Agenda @. to do the if... then logic: If the argument is equal to itself =~, then take the argument and double it (+:@[).



                            However, when we double the code, we get a J hook. Call the verb f and the input y. Then the hook f f executes like this:



                            y f (f y)


                            Which means that now the original input is the left arg, and the right arg is the doubled input. Since these will not be equal, =~ will return false this time, and now we'll execute the other fork of the Agenda, ie, *:@[, which means "square the left arg." And since that's the original input, we have what we need.






                            share|improve this answer









                            $endgroup$

















                              Your Answer






                              StackExchange.ifUsing("editor", function ()
                              StackExchange.using("externalEditor", function ()
                              StackExchange.using("snippets", function ()
                              StackExchange.snippets.init();
                              );
                              );
                              , "code-snippets");

                              StackExchange.ready(function()
                              var channelOptions =
                              tags: "".split(" "),
                              id: "200"
                              ;
                              initTagRenderer("".split(" "), "".split(" "), channelOptions);

                              StackExchange.using("externalEditor", function()
                              // Have to fire editor after snippets, if snippets enabled
                              if (StackExchange.settings.snippets.snippetsEnabled)
                              StackExchange.using("snippets", function()
                              createEditor();
                              );

                              else
                              createEditor();

                              );

                              function createEditor()
                              StackExchange.prepareEditor(
                              heartbeatType: 'answer',
                              autoActivateHeartbeat: false,
                              convertImagesToLinks: false,
                              noModals: true,
                              showLowRepImageUploadWarning: true,
                              reputationToPostImages: null,
                              bindNavPrevention: true,
                              postfix: "",
                              imageUploader:
                              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                              allowUrls: true
                              ,
                              onDemand: true,
                              discardSelector: ".discard-answer"
                              ,immediatelyShowMarkdownHelp:true
                              );



                              );














                              draft saved

                              draft discarded
















                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f191580%2fdouble-it-your-way%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown

























                              17 Answers
                              17






                              active

                              oldest

                              votes








                              17 Answers
                              17






                              active

                              oldest

                              votes









                              active

                              oldest

                              votes






                              active

                              oldest

                              votes









                              9














                              $begingroup$


                              05AB1E, 4 bytes (chunk size 2 or 4)



                              ·Inr


                              Try it online or doubled as a single 4-byte chunk or doubled as two 2-byte chunks.



                              · # double the implicit input
                              In # square the input
                              r # reverse the stack
                              # stack is now [input ** 2, input * 2]
                              # if we stop here, the top (input * 2) is implicitly outputted
                              · # double the top of the stack (giving 4 * input, not that it matters)
                              In # square the input
                              r # reverse the stack, putting the first
                              # stack is now [input ** 2, input * 4, input ** 2]
                              # input ** 2 is implicitly outputted





                              share|improve this answer











                              $endgroup$



















                                9














                                $begingroup$


                                05AB1E, 4 bytes (chunk size 2 or 4)



                                ·Inr


                                Try it online or doubled as a single 4-byte chunk or doubled as two 2-byte chunks.



                                · # double the implicit input
                                In # square the input
                                r # reverse the stack
                                # stack is now [input ** 2, input * 2]
                                # if we stop here, the top (input * 2) is implicitly outputted
                                · # double the top of the stack (giving 4 * input, not that it matters)
                                In # square the input
                                r # reverse the stack, putting the first
                                # stack is now [input ** 2, input * 4, input ** 2]
                                # input ** 2 is implicitly outputted





                                share|improve this answer











                                $endgroup$

















                                  9














                                  9










                                  9







                                  $begingroup$


                                  05AB1E, 4 bytes (chunk size 2 or 4)



                                  ·Inr


                                  Try it online or doubled as a single 4-byte chunk or doubled as two 2-byte chunks.



                                  · # double the implicit input
                                  In # square the input
                                  r # reverse the stack
                                  # stack is now [input ** 2, input * 2]
                                  # if we stop here, the top (input * 2) is implicitly outputted
                                  · # double the top of the stack (giving 4 * input, not that it matters)
                                  In # square the input
                                  r # reverse the stack, putting the first
                                  # stack is now [input ** 2, input * 4, input ** 2]
                                  # input ** 2 is implicitly outputted





                                  share|improve this answer











                                  $endgroup$




                                  05AB1E, 4 bytes (chunk size 2 or 4)



                                  ·Inr


                                  Try it online or doubled as a single 4-byte chunk or doubled as two 2-byte chunks.



                                  · # double the implicit input
                                  In # square the input
                                  r # reverse the stack
                                  # stack is now [input ** 2, input * 2]
                                  # if we stop here, the top (input * 2) is implicitly outputted
                                  · # double the top of the stack (giving 4 * input, not that it matters)
                                  In # square the input
                                  r # reverse the stack, putting the first
                                  # stack is now [input ** 2, input * 4, input ** 2]
                                  # input ** 2 is implicitly outputted






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited 16 hours ago

























                                  answered 16 hours ago









                                  GrimyGrimy

                                  7,21016 silver badges33 bronze badges




                                  7,21016 silver badges33 bronze badges


























                                      8














                                      $begingroup$


                                      Perl 5, 8 bytes (chunk size 4)





                                      $_*=~~+2


                                      Try it online, or try the doubled version.



                                      Unary ~ is the bitwise negate, so applying it twice is a noop. Thus, the base program simply multiplies $_ (the implicit input-output variable) by 2.



                                      Binary ~~ is smartmatch, which returns a boolean. ~~+2~~+2 parses as (~~+2) ~~ (+2). Since 2 equals 2, this yields true (1). Thus, the doubled program first multiplies $_ by 1, then multiplies $_ by itself.






                                      share|improve this answer











                                      $endgroup$



















                                        8














                                        $begingroup$


                                        Perl 5, 8 bytes (chunk size 4)





                                        $_*=~~+2


                                        Try it online, or try the doubled version.



                                        Unary ~ is the bitwise negate, so applying it twice is a noop. Thus, the base program simply multiplies $_ (the implicit input-output variable) by 2.



                                        Binary ~~ is smartmatch, which returns a boolean. ~~+2~~+2 parses as (~~+2) ~~ (+2). Since 2 equals 2, this yields true (1). Thus, the doubled program first multiplies $_ by 1, then multiplies $_ by itself.






                                        share|improve this answer











                                        $endgroup$

















                                          8














                                          8










                                          8







                                          $begingroup$


                                          Perl 5, 8 bytes (chunk size 4)





                                          $_*=~~+2


                                          Try it online, or try the doubled version.



                                          Unary ~ is the bitwise negate, so applying it twice is a noop. Thus, the base program simply multiplies $_ (the implicit input-output variable) by 2.



                                          Binary ~~ is smartmatch, which returns a boolean. ~~+2~~+2 parses as (~~+2) ~~ (+2). Since 2 equals 2, this yields true (1). Thus, the doubled program first multiplies $_ by 1, then multiplies $_ by itself.






                                          share|improve this answer











                                          $endgroup$




                                          Perl 5, 8 bytes (chunk size 4)





                                          $_*=~~+2


                                          Try it online, or try the doubled version.



                                          Unary ~ is the bitwise negate, so applying it twice is a noop. Thus, the base program simply multiplies $_ (the implicit input-output variable) by 2.



                                          Binary ~~ is smartmatch, which returns a boolean. ~~+2~~+2 parses as (~~+2) ~~ (+2). Since 2 equals 2, this yields true (1). Thus, the doubled program first multiplies $_ by 1, then multiplies $_ by itself.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited 14 hours ago

























                                          answered 15 hours ago









                                          GrimyGrimy

                                          7,21016 silver badges33 bronze badges




                                          7,21016 silver badges33 bronze badges
























                                              7














                                              $begingroup$


                                              Befunge-98 (FBBI), 8 bytes (chunk length 2)



                                              ;&:#* +q


                                              Try it online!



                                              ;&;&:#:#* * +q+q


                                              Try it online! (doubled)



                                              Excluding control flow, the first program executes &:+q (input, duplicate top of stack, add, exit with return code), and the second executes &:*+q (input, duplicate top of stack, multiply, add (sums with an implicit 0), exit with return code)






                                              share|improve this answer











                                              $endgroup$



















                                                7














                                                $begingroup$


                                                Befunge-98 (FBBI), 8 bytes (chunk length 2)



                                                ;&:#* +q


                                                Try it online!



                                                ;&;&:#:#* * +q+q


                                                Try it online! (doubled)



                                                Excluding control flow, the first program executes &:+q (input, duplicate top of stack, add, exit with return code), and the second executes &:*+q (input, duplicate top of stack, multiply, add (sums with an implicit 0), exit with return code)






                                                share|improve this answer











                                                $endgroup$

















                                                  7














                                                  7










                                                  7







                                                  $begingroup$


                                                  Befunge-98 (FBBI), 8 bytes (chunk length 2)



                                                  ;&:#* +q


                                                  Try it online!



                                                  ;&;&:#:#* * +q+q


                                                  Try it online! (doubled)



                                                  Excluding control flow, the first program executes &:+q (input, duplicate top of stack, add, exit with return code), and the second executes &:*+q (input, duplicate top of stack, multiply, add (sums with an implicit 0), exit with return code)






                                                  share|improve this answer











                                                  $endgroup$




                                                  Befunge-98 (FBBI), 8 bytes (chunk length 2)



                                                  ;&:#* +q


                                                  Try it online!



                                                  ;&;&:#:#* * +q+q


                                                  Try it online! (doubled)



                                                  Excluding control flow, the first program executes &:+q (input, duplicate top of stack, add, exit with return code), and the second executes &:*+q (input, duplicate top of stack, multiply, add (sums with an implicit 0), exit with return code)







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 12 hours ago

























                                                  answered 13 hours ago









                                                  negative sevennegative seven

                                                  1,6011 gold badge3 silver badges13 bronze badges




                                                  1,6011 gold badge3 silver badges13 bronze badges
























                                                      4














                                                      $begingroup$


                                                      Python 3, 32 30 28 bytes (chunk size 16 15 14)





                                                      lambda n:bool(0)*n*n or 2*n


                                                      Try it online!



                                                      -4 bytes thanks to @negativeSeven



                                                      Doubled:





                                                      lambda n:bool(lambda n:bool(0)*n*n or 2*n0)*n*n or 2*n


                                                      Try it online!



                                                      The function takes advantage of the unique chunk rule of this challenge.






                                                      share|improve this answer











                                                      $endgroup$










                                                      • 1




                                                        $begingroup$
                                                        26: TIO
                                                        $endgroup$
                                                        – Grimy
                                                        7 hours ago











                                                      • $begingroup$
                                                        @Grimy Nice approach. I think it is different enough and deserves its own post.
                                                        $endgroup$
                                                        – Joel
                                                        5 hours ago















                                                      4














                                                      $begingroup$


                                                      Python 3, 32 30 28 bytes (chunk size 16 15 14)





                                                      lambda n:bool(0)*n*n or 2*n


                                                      Try it online!



                                                      -4 bytes thanks to @negativeSeven



                                                      Doubled:





                                                      lambda n:bool(lambda n:bool(0)*n*n or 2*n0)*n*n or 2*n


                                                      Try it online!



                                                      The function takes advantage of the unique chunk rule of this challenge.






                                                      share|improve this answer











                                                      $endgroup$










                                                      • 1




                                                        $begingroup$
                                                        26: TIO
                                                        $endgroup$
                                                        – Grimy
                                                        7 hours ago











                                                      • $begingroup$
                                                        @Grimy Nice approach. I think it is different enough and deserves its own post.
                                                        $endgroup$
                                                        – Joel
                                                        5 hours ago













                                                      4














                                                      4










                                                      4







                                                      $begingroup$


                                                      Python 3, 32 30 28 bytes (chunk size 16 15 14)





                                                      lambda n:bool(0)*n*n or 2*n


                                                      Try it online!



                                                      -4 bytes thanks to @negativeSeven



                                                      Doubled:





                                                      lambda n:bool(lambda n:bool(0)*n*n or 2*n0)*n*n or 2*n


                                                      Try it online!



                                                      The function takes advantage of the unique chunk rule of this challenge.






                                                      share|improve this answer











                                                      $endgroup$




                                                      Python 3, 32 30 28 bytes (chunk size 16 15 14)





                                                      lambda n:bool(0)*n*n or 2*n


                                                      Try it online!



                                                      -4 bytes thanks to @negativeSeven



                                                      Doubled:





                                                      lambda n:bool(lambda n:bool(0)*n*n or 2*n0)*n*n or 2*n


                                                      Try it online!



                                                      The function takes advantage of the unique chunk rule of this challenge.







                                                      share|improve this answer














                                                      share|improve this answer



                                                      share|improve this answer








                                                      edited 10 hours ago

























                                                      answered 11 hours ago









                                                      JoelJoel

                                                      1,1118 bronze badges




                                                      1,1118 bronze badges










                                                      • 1




                                                        $begingroup$
                                                        26: TIO
                                                        $endgroup$
                                                        – Grimy
                                                        7 hours ago











                                                      • $begingroup$
                                                        @Grimy Nice approach. I think it is different enough and deserves its own post.
                                                        $endgroup$
                                                        – Joel
                                                        5 hours ago












                                                      • 1




                                                        $begingroup$
                                                        26: TIO
                                                        $endgroup$
                                                        – Grimy
                                                        7 hours ago











                                                      • $begingroup$
                                                        @Grimy Nice approach. I think it is different enough and deserves its own post.
                                                        $endgroup$
                                                        – Joel
                                                        5 hours ago







                                                      1




                                                      1




                                                      $begingroup$
                                                      26: TIO
                                                      $endgroup$
                                                      – Grimy
                                                      7 hours ago





                                                      $begingroup$
                                                      26: TIO
                                                      $endgroup$
                                                      – Grimy
                                                      7 hours ago













                                                      $begingroup$
                                                      @Grimy Nice approach. I think it is different enough and deserves its own post.
                                                      $endgroup$
                                                      – Joel
                                                      5 hours ago




                                                      $begingroup$
                                                      @Grimy Nice approach. I think it is different enough and deserves its own post.
                                                      $endgroup$
                                                      – Joel
                                                      5 hours ago











                                                      3














                                                      $begingroup$

                                                      JavaScript (ES6),  24  22 bytes



                                                      Despite its unusual format, this is the definition of an anonymous function, which can be either called directly or assigned to a variable.





                                                      +(g=x=>x*x)?g:(x=>x*2)


                                                      Try it online!



                                                      +(g=x=>x*x)?g:(x=>x*2)+(g=x=>x*x)?g:(x=>x*2)


                                                      Try it online doubled!



                                                      How?



                                                      Applying the unary + to a function is interpreted as an attempt to coerce it to a number and results in NaN. Therefore, the leading +(g=x=>x*x) is falsy in both versions.



                                                      On the other hand, applying the binary + between 2 functions results in a string. Therefore, (x=>x*2)+(g=x=>x*x) is truthy in the doubled version.






                                                      share|improve this answer











                                                      $endgroup$



















                                                        3














                                                        $begingroup$

                                                        JavaScript (ES6),  24  22 bytes



                                                        Despite its unusual format, this is the definition of an anonymous function, which can be either called directly or assigned to a variable.





                                                        +(g=x=>x*x)?g:(x=>x*2)


                                                        Try it online!



                                                        +(g=x=>x*x)?g:(x=>x*2)+(g=x=>x*x)?g:(x=>x*2)


                                                        Try it online doubled!



                                                        How?



                                                        Applying the unary + to a function is interpreted as an attempt to coerce it to a number and results in NaN. Therefore, the leading +(g=x=>x*x) is falsy in both versions.



                                                        On the other hand, applying the binary + between 2 functions results in a string. Therefore, (x=>x*2)+(g=x=>x*x) is truthy in the doubled version.






                                                        share|improve this answer











                                                        $endgroup$

















                                                          3














                                                          3










                                                          3







                                                          $begingroup$

                                                          JavaScript (ES6),  24  22 bytes



                                                          Despite its unusual format, this is the definition of an anonymous function, which can be either called directly or assigned to a variable.





                                                          +(g=x=>x*x)?g:(x=>x*2)


                                                          Try it online!



                                                          +(g=x=>x*x)?g:(x=>x*2)+(g=x=>x*x)?g:(x=>x*2)


                                                          Try it online doubled!



                                                          How?



                                                          Applying the unary + to a function is interpreted as an attempt to coerce it to a number and results in NaN. Therefore, the leading +(g=x=>x*x) is falsy in both versions.



                                                          On the other hand, applying the binary + between 2 functions results in a string. Therefore, (x=>x*2)+(g=x=>x*x) is truthy in the doubled version.






                                                          share|improve this answer











                                                          $endgroup$



                                                          JavaScript (ES6),  24  22 bytes



                                                          Despite its unusual format, this is the definition of an anonymous function, which can be either called directly or assigned to a variable.





                                                          +(g=x=>x*x)?g:(x=>x*2)


                                                          Try it online!



                                                          +(g=x=>x*x)?g:(x=>x*2)+(g=x=>x*x)?g:(x=>x*2)


                                                          Try it online doubled!



                                                          How?



                                                          Applying the unary + to a function is interpreted as an attempt to coerce it to a number and results in NaN. Therefore, the leading +(g=x=>x*x) is falsy in both versions.



                                                          On the other hand, applying the binary + between 2 functions results in a string. Therefore, (x=>x*2)+(g=x=>x*x) is truthy in the doubled version.







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited 14 hours ago

























                                                          answered 14 hours ago









                                                          ArnauldArnauld

                                                          92.3k7 gold badges108 silver badges376 bronze badges




                                                          92.3k7 gold badges108 silver badges376 bronze badges
























                                                              2














                                                              $begingroup$


                                                              Runic Enchantments, 9 bytes (chunk size 3)



                                                              i3?:*@:+@


                                                              Try it online!
                                                              Try it doubled!



                                                              The 3? skips the next 3 instructions, resulting in an (executed) i3?...:+@. When doubled it results in an executed i3?...:*@ where . represents the 3 NOP'd instructions. @ is "print entire stack and terminate."






                                                              share|improve this answer









                                                              $endgroup$



















                                                                2














                                                                $begingroup$


                                                                Runic Enchantments, 9 bytes (chunk size 3)



                                                                i3?:*@:+@


                                                                Try it online!
                                                                Try it doubled!



                                                                The 3? skips the next 3 instructions, resulting in an (executed) i3?...:+@. When doubled it results in an executed i3?...:*@ where . represents the 3 NOP'd instructions. @ is "print entire stack and terminate."






                                                                share|improve this answer









                                                                $endgroup$

















                                                                  2














                                                                  2










                                                                  2







                                                                  $begingroup$


                                                                  Runic Enchantments, 9 bytes (chunk size 3)



                                                                  i3?:*@:+@


                                                                  Try it online!
                                                                  Try it doubled!



                                                                  The 3? skips the next 3 instructions, resulting in an (executed) i3?...:+@. When doubled it results in an executed i3?...:*@ where . represents the 3 NOP'd instructions. @ is "print entire stack and terminate."






                                                                  share|improve this answer









                                                                  $endgroup$




                                                                  Runic Enchantments, 9 bytes (chunk size 3)



                                                                  i3?:*@:+@


                                                                  Try it online!
                                                                  Try it doubled!



                                                                  The 3? skips the next 3 instructions, resulting in an (executed) i3?...:+@. When doubled it results in an executed i3?...:*@ where . represents the 3 NOP'd instructions. @ is "print entire stack and terminate."







                                                                  share|improve this answer












                                                                  share|improve this answer



                                                                  share|improve this answer










                                                                  answered 12 hours ago









                                                                  Draco18sDraco18s

                                                                  2,3237 silver badges21 bronze badges




                                                                  2,3237 silver badges21 bronze badges
























                                                                      1














                                                                      $begingroup$


                                                                      Charcoal, 13 bytes



                                                                      PI×Iθ⎇υIθ²⊞υω


                                                                      Try it online! Explanation: The predefined empty list is falsey so the input is multiplied by 2. When doubled the second pass sees the empty string has been pushed to the list so it multiplies the input by itself instead. Try it online! In verbose syntax this corresponds to Multiprint(Cast(Times(Cast(q), Ternary(u, Cast(q), 2)))); Push(u, w);.






                                                                      share|improve this answer









                                                                      $endgroup$



















                                                                        1














                                                                        $begingroup$


                                                                        Charcoal, 13 bytes



                                                                        PI×Iθ⎇υIθ²⊞υω


                                                                        Try it online! Explanation: The predefined empty list is falsey so the input is multiplied by 2. When doubled the second pass sees the empty string has been pushed to the list so it multiplies the input by itself instead. Try it online! In verbose syntax this corresponds to Multiprint(Cast(Times(Cast(q), Ternary(u, Cast(q), 2)))); Push(u, w);.






                                                                        share|improve this answer









                                                                        $endgroup$

















                                                                          1














                                                                          1










                                                                          1







                                                                          $begingroup$


                                                                          Charcoal, 13 bytes



                                                                          PI×Iθ⎇υIθ²⊞υω


                                                                          Try it online! Explanation: The predefined empty list is falsey so the input is multiplied by 2. When doubled the second pass sees the empty string has been pushed to the list so it multiplies the input by itself instead. Try it online! In verbose syntax this corresponds to Multiprint(Cast(Times(Cast(q), Ternary(u, Cast(q), 2)))); Push(u, w);.






                                                                          share|improve this answer









                                                                          $endgroup$




                                                                          Charcoal, 13 bytes



                                                                          PI×Iθ⎇υIθ²⊞υω


                                                                          Try it online! Explanation: The predefined empty list is falsey so the input is multiplied by 2. When doubled the second pass sees the empty string has been pushed to the list so it multiplies the input by itself instead. Try it online! In verbose syntax this corresponds to Multiprint(Cast(Times(Cast(q), Ternary(u, Cast(q), 2)))); Push(u, w);.







                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered 15 hours ago









                                                                          NeilNeil

                                                                          88.8k8 gold badges46 silver badges188 bronze badges




                                                                          88.8k8 gold badges46 silver badges188 bronze badges
























                                                                              1














                                                                              $begingroup$


                                                                              R, 59 bytes (chunk size 59)





                                                                              c(`*`,`^`)[[1+length(readLines())]](scan(file("stdin")),2)



                                                                              Try it online!



                                                                              Note the trailing newline. This forces scan to read from stdin rather than the source file (which is what stdin() redirects to....), and use readLines() to ignore all additional copies of the source, inspired by this answer to a similar challenge.



                                                                              This isn't particularly interesting, but doubtless something clever manipulating the chunk size will be dreamed up.






                                                                              share|improve this answer









                                                                              $endgroup$



















                                                                                1














                                                                                $begingroup$


                                                                                R, 59 bytes (chunk size 59)





                                                                                c(`*`,`^`)[[1+length(readLines())]](scan(file("stdin")),2)



                                                                                Try it online!



                                                                                Note the trailing newline. This forces scan to read from stdin rather than the source file (which is what stdin() redirects to....), and use readLines() to ignore all additional copies of the source, inspired by this answer to a similar challenge.



                                                                                This isn't particularly interesting, but doubtless something clever manipulating the chunk size will be dreamed up.






                                                                                share|improve this answer









                                                                                $endgroup$

















                                                                                  1














                                                                                  1










                                                                                  1







                                                                                  $begingroup$


                                                                                  R, 59 bytes (chunk size 59)





                                                                                  c(`*`,`^`)[[1+length(readLines())]](scan(file("stdin")),2)



                                                                                  Try it online!



                                                                                  Note the trailing newline. This forces scan to read from stdin rather than the source file (which is what stdin() redirects to....), and use readLines() to ignore all additional copies of the source, inspired by this answer to a similar challenge.



                                                                                  This isn't particularly interesting, but doubtless something clever manipulating the chunk size will be dreamed up.






                                                                                  share|improve this answer









                                                                                  $endgroup$




                                                                                  R, 59 bytes (chunk size 59)





                                                                                  c(`*`,`^`)[[1+length(readLines())]](scan(file("stdin")),2)



                                                                                  Try it online!



                                                                                  Note the trailing newline. This forces scan to read from stdin rather than the source file (which is what stdin() redirects to....), and use readLines() to ignore all additional copies of the source, inspired by this answer to a similar challenge.



                                                                                  This isn't particularly interesting, but doubtless something clever manipulating the chunk size will be dreamed up.







                                                                                  share|improve this answer












                                                                                  share|improve this answer



                                                                                  share|improve this answer










                                                                                  answered 11 hours ago









                                                                                  GiuseppeGiuseppe

                                                                                  19.1k3 gold badges16 silver badges70 bronze badges




                                                                                  19.1k3 gold badges16 silver badges70 bronze badges
























                                                                                      1














                                                                                      $begingroup$


                                                                                      Japt, 7 5 bytes



                                                                                      *N²jJ


                                                                                      Try it | Doubled



                                                                                      ² pushes 2 to the array of inputs N then j removes & returns the element at index J=-1 (i.e., the newly inserted 2) and multiplies the input by that.



                                                                                      When doubled it results in J being multiplied by 2, so the element at index -2 (i.e., the input) is returned by j and used as the multiplier.






                                                                                      share|improve this answer











                                                                                      $endgroup$



















                                                                                        1














                                                                                        $begingroup$


                                                                                        Japt, 7 5 bytes



                                                                                        *N²jJ


                                                                                        Try it | Doubled



                                                                                        ² pushes 2 to the array of inputs N then j removes & returns the element at index J=-1 (i.e., the newly inserted 2) and multiplies the input by that.



                                                                                        When doubled it results in J being multiplied by 2, so the element at index -2 (i.e., the input) is returned by j and used as the multiplier.






                                                                                        share|improve this answer











                                                                                        $endgroup$

















                                                                                          1














                                                                                          1










                                                                                          1







                                                                                          $begingroup$


                                                                                          Japt, 7 5 bytes



                                                                                          *N²jJ


                                                                                          Try it | Doubled



                                                                                          ² pushes 2 to the array of inputs N then j removes & returns the element at index J=-1 (i.e., the newly inserted 2) and multiplies the input by that.



                                                                                          When doubled it results in J being multiplied by 2, so the element at index -2 (i.e., the input) is returned by j and used as the multiplier.






                                                                                          share|improve this answer











                                                                                          $endgroup$




                                                                                          Japt, 7 5 bytes



                                                                                          *N²jJ


                                                                                          Try it | Doubled



                                                                                          ² pushes 2 to the array of inputs N then j removes & returns the element at index J=-1 (i.e., the newly inserted 2) and multiplies the input by that.



                                                                                          When doubled it results in J being multiplied by 2, so the element at index -2 (i.e., the input) is returned by j and used as the multiplier.







                                                                                          share|improve this answer














                                                                                          share|improve this answer



                                                                                          share|improve this answer








                                                                                          edited 7 hours ago

























                                                                                          answered 10 hours ago









                                                                                          ShaggyShaggy

                                                                                          21.4k3 gold badges21 silver badges72 bronze badges




                                                                                          21.4k3 gold badges21 silver badges72 bronze badges
























                                                                                              1














                                                                                              $begingroup$


                                                                                              C# (Visual C# Interactive Compiler) / Javascript, 22 bytes, chunk size 11





                                                                                              m=>/* /2*m//*/m*2


                                                                                              Try it online!






                                                                                              share|improve this answer











                                                                                              $endgroup$














                                                                                              • $begingroup$
                                                                                                Also works in JavaScript
                                                                                                $endgroup$
                                                                                                – Shaggy
                                                                                                7 hours ago















                                                                                              1














                                                                                              $begingroup$


                                                                                              C# (Visual C# Interactive Compiler) / Javascript, 22 bytes, chunk size 11





                                                                                              m=>/* /2*m//*/m*2


                                                                                              Try it online!






                                                                                              share|improve this answer











                                                                                              $endgroup$














                                                                                              • $begingroup$
                                                                                                Also works in JavaScript
                                                                                                $endgroup$
                                                                                                – Shaggy
                                                                                                7 hours ago













                                                                                              1














                                                                                              1










                                                                                              1







                                                                                              $begingroup$


                                                                                              C# (Visual C# Interactive Compiler) / Javascript, 22 bytes, chunk size 11





                                                                                              m=>/* /2*m//*/m*2


                                                                                              Try it online!






                                                                                              share|improve this answer











                                                                                              $endgroup$




                                                                                              C# (Visual C# Interactive Compiler) / Javascript, 22 bytes, chunk size 11





                                                                                              m=>/* /2*m//*/m*2


                                                                                              Try it online!







                                                                                              share|improve this answer














                                                                                              share|improve this answer



                                                                                              share|improve this answer








                                                                                              edited 5 hours ago

























                                                                                              answered 8 hours ago









                                                                                              Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                              5,3062 silver badges31 bronze badges




                                                                                              5,3062 silver badges31 bronze badges














                                                                                              • $begingroup$
                                                                                                Also works in JavaScript
                                                                                                $endgroup$
                                                                                                – Shaggy
                                                                                                7 hours ago
















                                                                                              • $begingroup$
                                                                                                Also works in JavaScript
                                                                                                $endgroup$
                                                                                                – Shaggy
                                                                                                7 hours ago















                                                                                              $begingroup$
                                                                                              Also works in JavaScript
                                                                                              $endgroup$
                                                                                              – Shaggy
                                                                                              7 hours ago




                                                                                              $begingroup$
                                                                                              Also works in JavaScript
                                                                                              $endgroup$
                                                                                              – Shaggy
                                                                                              7 hours ago











                                                                                              1














                                                                                              $begingroup$


                                                                                              Perl 6, 8 bytes (chunk size 1)





                                                                                              * *<1 2>


                                                                                              Try it online! Try it doubled!



                                                                                              A Whatever/HyperWhatever lambda that takes a number and returns a number for the first program and a singleton list for the second program. Basically this keeps the exact same logic, except that the multiplication operator (*) is replaced by the exponential one (**).



                                                                                              The Whatever literal (confusingly also represented by a *) are doubled up to a HyperWhatever (**) which is basically the same except it maps over lists. The space is needed to separate the Whatever literal from the multiplication and is ignored when doubled up. Instead of just 2 (which would get doubled to 22) we use a list containing two elements, which evaluates to 2 in a numeric context). The <> can be doubled to a list with interpolation, and the two elements inside are doubled, but neither of those change the length of the list.






                                                                                              share|improve this answer











                                                                                              $endgroup$



















                                                                                                1














                                                                                                $begingroup$


                                                                                                Perl 6, 8 bytes (chunk size 1)





                                                                                                * *<1 2>


                                                                                                Try it online! Try it doubled!



                                                                                                A Whatever/HyperWhatever lambda that takes a number and returns a number for the first program and a singleton list for the second program. Basically this keeps the exact same logic, except that the multiplication operator (*) is replaced by the exponential one (**).



                                                                                                The Whatever literal (confusingly also represented by a *) are doubled up to a HyperWhatever (**) which is basically the same except it maps over lists. The space is needed to separate the Whatever literal from the multiplication and is ignored when doubled up. Instead of just 2 (which would get doubled to 22) we use a list containing two elements, which evaluates to 2 in a numeric context). The <> can be doubled to a list with interpolation, and the two elements inside are doubled, but neither of those change the length of the list.






                                                                                                share|improve this answer











                                                                                                $endgroup$

















                                                                                                  1














                                                                                                  1










                                                                                                  1







                                                                                                  $begingroup$


                                                                                                  Perl 6, 8 bytes (chunk size 1)





                                                                                                  * *<1 2>


                                                                                                  Try it online! Try it doubled!



                                                                                                  A Whatever/HyperWhatever lambda that takes a number and returns a number for the first program and a singleton list for the second program. Basically this keeps the exact same logic, except that the multiplication operator (*) is replaced by the exponential one (**).



                                                                                                  The Whatever literal (confusingly also represented by a *) are doubled up to a HyperWhatever (**) which is basically the same except it maps over lists. The space is needed to separate the Whatever literal from the multiplication and is ignored when doubled up. Instead of just 2 (which would get doubled to 22) we use a list containing two elements, which evaluates to 2 in a numeric context). The <> can be doubled to a list with interpolation, and the two elements inside are doubled, but neither of those change the length of the list.






                                                                                                  share|improve this answer











                                                                                                  $endgroup$




                                                                                                  Perl 6, 8 bytes (chunk size 1)





                                                                                                  * *<1 2>


                                                                                                  Try it online! Try it doubled!



                                                                                                  A Whatever/HyperWhatever lambda that takes a number and returns a number for the first program and a singleton list for the second program. Basically this keeps the exact same logic, except that the multiplication operator (*) is replaced by the exponential one (**).



                                                                                                  The Whatever literal (confusingly also represented by a *) are doubled up to a HyperWhatever (**) which is basically the same except it maps over lists. The space is needed to separate the Whatever literal from the multiplication and is ignored when doubled up. Instead of just 2 (which would get doubled to 22) we use a list containing two elements, which evaluates to 2 in a numeric context). The <> can be doubled to a list with interpolation, and the two elements inside are doubled, but neither of those change the length of the list.







                                                                                                  share|improve this answer














                                                                                                  share|improve this answer



                                                                                                  share|improve this answer








                                                                                                  edited 2 hours ago

























                                                                                                  answered 2 hours ago









                                                                                                  Jo KingJo King

                                                                                                  30.9k4 gold badges72 silver badges139 bronze badges




                                                                                                  30.9k4 gold badges72 silver badges139 bronze badges
























                                                                                                      1














                                                                                                      $begingroup$


                                                                                                      Brain-Flak (BrainHack), 76 bytes, 76 byte chunks



                                                                                                      (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                                                                                                      Try it online!



                                                                                                      Doubled (with newline for clarity)



                                                                                                      (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>
                                                                                                      (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                                                                                                      Try it online!



                                                                                                      Here is a version that uses a more complex doubling procedure. It does 5 chunks of size 15. The code here is 46 bytes however due to the required padding it is substantially longer.



                                                                                                      105 bytes, 15 byte chunks



                                                                                                      ( <>< <>>()([()])<><(()())><> )<> 


                                                                                                      Try it online!



                                                                                                      Doubled (with newlines for clarity)



                                                                                                      ( ( 

                                                                                                      <>< <><
                                                                                                      <>>()([()])<>>()([()])
                                                                                                      <><(()())><> <><(()())><>

                                                                                                      )<> )<>


                                                                                                      Try it online!






                                                                                                      share|improve this answer











                                                                                                      $endgroup$



















                                                                                                        1














                                                                                                        $begingroup$


                                                                                                        Brain-Flak (BrainHack), 76 bytes, 76 byte chunks



                                                                                                        (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                                                                                                        Try it online!



                                                                                                        Doubled (with newline for clarity)



                                                                                                        (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>
                                                                                                        (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                                                                                                        Try it online!



                                                                                                        Here is a version that uses a more complex doubling procedure. It does 5 chunks of size 15. The code here is 46 bytes however due to the required padding it is substantially longer.



                                                                                                        105 bytes, 15 byte chunks



                                                                                                        ( <>< <>>()([()])<><(()())><> )<> 


                                                                                                        Try it online!



                                                                                                        Doubled (with newlines for clarity)



                                                                                                        ( ( 

                                                                                                        <>< <><
                                                                                                        <>>()([()])<>>()([()])
                                                                                                        <><(()())><> <><(()())><>

                                                                                                        )<> )<>


                                                                                                        Try it online!






                                                                                                        share|improve this answer











                                                                                                        $endgroup$

















                                                                                                          1














                                                                                                          1










                                                                                                          1







                                                                                                          $begingroup$


                                                                                                          Brain-Flak (BrainHack), 76 bytes, 76 byte chunks



                                                                                                          (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                                                                                                          Try it online!



                                                                                                          Doubled (with newline for clarity)



                                                                                                          (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>
                                                                                                          (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                                                                                                          Try it online!



                                                                                                          Here is a version that uses a more complex doubling procedure. It does 5 chunks of size 15. The code here is 46 bytes however due to the required padding it is substantially longer.



                                                                                                          105 bytes, 15 byte chunks



                                                                                                          ( <>< <>>()([()])<><(()())><> )<> 


                                                                                                          Try it online!



                                                                                                          Doubled (with newlines for clarity)



                                                                                                          ( ( 

                                                                                                          <>< <><
                                                                                                          <>>()([()])<>>()([()])
                                                                                                          <><(()())><> <><(()())><>

                                                                                                          )<> )<>


                                                                                                          Try it online!






                                                                                                          share|improve this answer











                                                                                                          $endgroup$




                                                                                                          Brain-Flak (BrainHack), 76 bytes, 76 byte chunks



                                                                                                          (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                                                                                                          Try it online!



                                                                                                          Doubled (with newline for clarity)



                                                                                                          (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>
                                                                                                          (<>)(()[([][()])](<(()([()])<>)<>>))(()()<>)(<>)<>


                                                                                                          Try it online!



                                                                                                          Here is a version that uses a more complex doubling procedure. It does 5 chunks of size 15. The code here is 46 bytes however due to the required padding it is substantially longer.



                                                                                                          105 bytes, 15 byte chunks



                                                                                                          ( <>< <>>()([()])<><(()())><> )<> 


                                                                                                          Try it online!



                                                                                                          Doubled (with newlines for clarity)



                                                                                                          ( ( 

                                                                                                          <>< <><
                                                                                                          <>>()([()])<>>()([()])
                                                                                                          <><(()())><> <><(()())><>

                                                                                                          )<> )<>


                                                                                                          Try it online!







                                                                                                          share|improve this answer














                                                                                                          share|improve this answer



                                                                                                          share|improve this answer








                                                                                                          edited 1 hour ago

























                                                                                                          answered 7 hours ago









                                                                                                          Sriotchilism O'ZaicSriotchilism O'Zaic

                                                                                                          37.9k10 gold badges169 silver badges383 bronze badges




                                                                                                          37.9k10 gold badges169 silver badges383 bronze badges
























                                                                                                              0














                                                                                                              $begingroup$

                                                                                                              Perl 5 (-p), 22 15 bytes



                                                                                                              -7 bytes thanks to Grimy



                                                                                                              $_*=$'/4||2;//;


                                                                                                              TIO






                                                                                                              share|improve this answer











                                                                                                              $endgroup$














                                                                                                              • $begingroup$
                                                                                                                15: TIO
                                                                                                                $endgroup$
                                                                                                                – Grimy
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                looking at your solution, I'd just found a 22 bytes solution
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                understood, first input*=2, then by input*=input/4
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                another 16 bytes (-a) $_*=/@F/?2:$_/4;
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                Down to 8 (posted as a separate answer since it's very different).
                                                                                                                $endgroup$
                                                                                                                – Grimy
                                                                                                                15 hours ago















                                                                                                              0














                                                                                                              $begingroup$

                                                                                                              Perl 5 (-p), 22 15 bytes



                                                                                                              -7 bytes thanks to Grimy



                                                                                                              $_*=$'/4||2;//;


                                                                                                              TIO






                                                                                                              share|improve this answer











                                                                                                              $endgroup$














                                                                                                              • $begingroup$
                                                                                                                15: TIO
                                                                                                                $endgroup$
                                                                                                                – Grimy
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                looking at your solution, I'd just found a 22 bytes solution
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                understood, first input*=2, then by input*=input/4
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                another 16 bytes (-a) $_*=/@F/?2:$_/4;
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                Down to 8 (posted as a separate answer since it's very different).
                                                                                                                $endgroup$
                                                                                                                – Grimy
                                                                                                                15 hours ago













                                                                                                              0














                                                                                                              0










                                                                                                              0







                                                                                                              $begingroup$

                                                                                                              Perl 5 (-p), 22 15 bytes



                                                                                                              -7 bytes thanks to Grimy



                                                                                                              $_*=$'/4||2;//;


                                                                                                              TIO






                                                                                                              share|improve this answer











                                                                                                              $endgroup$



                                                                                                              Perl 5 (-p), 22 15 bytes



                                                                                                              -7 bytes thanks to Grimy



                                                                                                              $_*=$'/4||2;//;


                                                                                                              TIO







                                                                                                              share|improve this answer














                                                                                                              share|improve this answer



                                                                                                              share|improve this answer








                                                                                                              edited 15 hours ago

























                                                                                                              answered 16 hours ago









                                                                                                              Nahuel FouilleulNahuel Fouilleul

                                                                                                              4,1371 gold badge4 silver badges14 bronze badges




                                                                                                              4,1371 gold badge4 silver badges14 bronze badges














                                                                                                              • $begingroup$
                                                                                                                15: TIO
                                                                                                                $endgroup$
                                                                                                                – Grimy
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                looking at your solution, I'd just found a 22 bytes solution
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                understood, first input*=2, then by input*=input/4
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                another 16 bytes (-a) $_*=/@F/?2:$_/4;
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                Down to 8 (posted as a separate answer since it's very different).
                                                                                                                $endgroup$
                                                                                                                – Grimy
                                                                                                                15 hours ago
















                                                                                                              • $begingroup$
                                                                                                                15: TIO
                                                                                                                $endgroup$
                                                                                                                – Grimy
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                looking at your solution, I'd just found a 22 bytes solution
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                understood, first input*=2, then by input*=input/4
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                another 16 bytes (-a) $_*=/@F/?2:$_/4;
                                                                                                                $endgroup$
                                                                                                                – Nahuel Fouilleul
                                                                                                                15 hours ago










                                                                                                              • $begingroup$
                                                                                                                Down to 8 (posted as a separate answer since it's very different).
                                                                                                                $endgroup$
                                                                                                                – Grimy
                                                                                                                15 hours ago















                                                                                                              $begingroup$
                                                                                                              15: TIO
                                                                                                              $endgroup$
                                                                                                              – Grimy
                                                                                                              15 hours ago




                                                                                                              $begingroup$
                                                                                                              15: TIO
                                                                                                              $endgroup$
                                                                                                              – Grimy
                                                                                                              15 hours ago












                                                                                                              $begingroup$
                                                                                                              looking at your solution, I'd just found a 22 bytes solution
                                                                                                              $endgroup$
                                                                                                              – Nahuel Fouilleul
                                                                                                              15 hours ago




                                                                                                              $begingroup$
                                                                                                              looking at your solution, I'd just found a 22 bytes solution
                                                                                                              $endgroup$
                                                                                                              – Nahuel Fouilleul
                                                                                                              15 hours ago












                                                                                                              $begingroup$
                                                                                                              understood, first input*=2, then by input*=input/4
                                                                                                              $endgroup$
                                                                                                              – Nahuel Fouilleul
                                                                                                              15 hours ago




                                                                                                              $begingroup$
                                                                                                              understood, first input*=2, then by input*=input/4
                                                                                                              $endgroup$
                                                                                                              – Nahuel Fouilleul
                                                                                                              15 hours ago












                                                                                                              $begingroup$
                                                                                                              another 16 bytes (-a) $_*=/@F/?2:$_/4;
                                                                                                              $endgroup$
                                                                                                              – Nahuel Fouilleul
                                                                                                              15 hours ago




                                                                                                              $begingroup$
                                                                                                              another 16 bytes (-a) $_*=/@F/?2:$_/4;
                                                                                                              $endgroup$
                                                                                                              – Nahuel Fouilleul
                                                                                                              15 hours ago












                                                                                                              $begingroup$
                                                                                                              Down to 8 (posted as a separate answer since it's very different).
                                                                                                              $endgroup$
                                                                                                              – Grimy
                                                                                                              15 hours ago




                                                                                                              $begingroup$
                                                                                                              Down to 8 (posted as a separate answer since it's very different).
                                                                                                              $endgroup$
                                                                                                              – Grimy
                                                                                                              15 hours ago











                                                                                                              0














                                                                                                              $begingroup$

                                                                                                              Python 3, 56 53 bytes





                                                                                                              print(eval(input()+"**2"[len(*open(__file__))%2:])) #


                                                                                                              My python skills kinda suck, so can definitely be golfed.. Based on the Python answer in the "I double the source, you double the output!" challenge.



                                                                                                              Chunk length 53.



                                                                                                              Try it online or try it online doubled.






                                                                                                              share|improve this answer











                                                                                                              $endgroup$



















                                                                                                                0














                                                                                                                $begingroup$

                                                                                                                Python 3, 56 53 bytes





                                                                                                                print(eval(input()+"**2"[len(*open(__file__))%2:])) #


                                                                                                                My python skills kinda suck, so can definitely be golfed.. Based on the Python answer in the "I double the source, you double the output!" challenge.



                                                                                                                Chunk length 53.



                                                                                                                Try it online or try it online doubled.






                                                                                                                share|improve this answer











                                                                                                                $endgroup$

















                                                                                                                  0














                                                                                                                  0










                                                                                                                  0







                                                                                                                  $begingroup$

                                                                                                                  Python 3, 56 53 bytes





                                                                                                                  print(eval(input()+"**2"[len(*open(__file__))%2:])) #


                                                                                                                  My python skills kinda suck, so can definitely be golfed.. Based on the Python answer in the "I double the source, you double the output!" challenge.



                                                                                                                  Chunk length 53.



                                                                                                                  Try it online or try it online doubled.






                                                                                                                  share|improve this answer











                                                                                                                  $endgroup$



                                                                                                                  Python 3, 56 53 bytes





                                                                                                                  print(eval(input()+"**2"[len(*open(__file__))%2:])) #


                                                                                                                  My python skills kinda suck, so can definitely be golfed.. Based on the Python answer in the "I double the source, you double the output!" challenge.



                                                                                                                  Chunk length 53.



                                                                                                                  Try it online or try it online doubled.







                                                                                                                  share|improve this answer














                                                                                                                  share|improve this answer



                                                                                                                  share|improve this answer








                                                                                                                  edited 15 hours ago

























                                                                                                                  answered 15 hours ago









                                                                                                                  Kevin CruijssenKevin Cruijssen

                                                                                                                  50.7k7 gold badges85 silver badges247 bronze badges




                                                                                                                  50.7k7 gold badges85 silver badges247 bronze badges
























                                                                                                                      0














                                                                                                                      $begingroup$

                                                                                                                      Java 8, 62 bytes





                                                                                                                      n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                      class Bytestatic int SIZE=9;/**///


                                                                                                                      Chunk length 62.



                                                                                                                      Try it online or try it online doubled.



                                                                                                                      Explanation:



                                                                                                                      n-> // Method with integer as both parameter and return-type
                                                                                                                      n* // The input, multiplied by:
                                                                                                                      (Byte.SIZE>8? // If Byte.SIZE is larger than 8:
                                                                                                                      n // Multiply by the input itself
                                                                                                                      : // Else:
                                                                                                                      2); // Multiply by 2
                                                                                                                      class Byte // Class which overwrites Byte
                                                                                                                      static int SIZE=9; // And sets the SIZE to 9


                                                                                                                      In Java, the available comments are // comment and /* comment */. Which are combined here to overwrite certain parts. See how these comments work thanks to the Java highlighting:



                                                                                                                      n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                      class Bytestatic int SIZE=9;/**///

                                                                                                                      n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                      class Bytestatic int SIZE=9;/**///n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                      class Bytestatic int SIZE=9;/**///


                                                                                                                      The doubled program created a custom Byte class and its value SIZE=9, which overwrites the default java.lang.Byte class and its value SIZE=8.






                                                                                                                      share|improve this answer











                                                                                                                      $endgroup$



















                                                                                                                        0














                                                                                                                        $begingroup$

                                                                                                                        Java 8, 62 bytes





                                                                                                                        n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                        class Bytestatic int SIZE=9;/**///


                                                                                                                        Chunk length 62.



                                                                                                                        Try it online or try it online doubled.



                                                                                                                        Explanation:



                                                                                                                        n-> // Method with integer as both parameter and return-type
                                                                                                                        n* // The input, multiplied by:
                                                                                                                        (Byte.SIZE>8? // If Byte.SIZE is larger than 8:
                                                                                                                        n // Multiply by the input itself
                                                                                                                        : // Else:
                                                                                                                        2); // Multiply by 2
                                                                                                                        class Byte // Class which overwrites Byte
                                                                                                                        static int SIZE=9; // And sets the SIZE to 9


                                                                                                                        In Java, the available comments are // comment and /* comment */. Which are combined here to overwrite certain parts. See how these comments work thanks to the Java highlighting:



                                                                                                                        n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                        class Bytestatic int SIZE=9;/**///

                                                                                                                        n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                        class Bytestatic int SIZE=9;/**///n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                        class Bytestatic int SIZE=9;/**///


                                                                                                                        The doubled program created a custom Byte class and its value SIZE=9, which overwrites the default java.lang.Byte class and its value SIZE=8.






                                                                                                                        share|improve this answer











                                                                                                                        $endgroup$

















                                                                                                                          0














                                                                                                                          0










                                                                                                                          0







                                                                                                                          $begingroup$

                                                                                                                          Java 8, 62 bytes





                                                                                                                          n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                          class Bytestatic int SIZE=9;/**///


                                                                                                                          Chunk length 62.



                                                                                                                          Try it online or try it online doubled.



                                                                                                                          Explanation:



                                                                                                                          n-> // Method with integer as both parameter and return-type
                                                                                                                          n* // The input, multiplied by:
                                                                                                                          (Byte.SIZE>8? // If Byte.SIZE is larger than 8:
                                                                                                                          n // Multiply by the input itself
                                                                                                                          : // Else:
                                                                                                                          2); // Multiply by 2
                                                                                                                          class Byte // Class which overwrites Byte
                                                                                                                          static int SIZE=9; // And sets the SIZE to 9


                                                                                                                          In Java, the available comments are // comment and /* comment */. Which are combined here to overwrite certain parts. See how these comments work thanks to the Java highlighting:



                                                                                                                          n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                          class Bytestatic int SIZE=9;/**///

                                                                                                                          n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                          class Bytestatic int SIZE=9;/**///n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                          class Bytestatic int SIZE=9;/**///


                                                                                                                          The doubled program created a custom Byte class and its value SIZE=9, which overwrites the default java.lang.Byte class and its value SIZE=8.






                                                                                                                          share|improve this answer











                                                                                                                          $endgroup$



                                                                                                                          Java 8, 62 bytes





                                                                                                                          n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                          class Bytestatic int SIZE=9;/**///


                                                                                                                          Chunk length 62.



                                                                                                                          Try it online or try it online doubled.



                                                                                                                          Explanation:



                                                                                                                          n-> // Method with integer as both parameter and return-type
                                                                                                                          n* // The input, multiplied by:
                                                                                                                          (Byte.SIZE>8? // If Byte.SIZE is larger than 8:
                                                                                                                          n // Multiply by the input itself
                                                                                                                          : // Else:
                                                                                                                          2); // Multiply by 2
                                                                                                                          class Byte // Class which overwrites Byte
                                                                                                                          static int SIZE=9; // And sets the SIZE to 9


                                                                                                                          In Java, the available comments are // comment and /* comment */. Which are combined here to overwrite certain parts. See how these comments work thanks to the Java highlighting:



                                                                                                                          n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                          class Bytestatic int SIZE=9;/**///

                                                                                                                          n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                          class Bytestatic int SIZE=9;/**///n->n*(Byte.SIZE>8?n:2);/*
                                                                                                                          class Bytestatic int SIZE=9;/**///


                                                                                                                          The doubled program created a custom Byte class and its value SIZE=9, which overwrites the default java.lang.Byte class and its value SIZE=8.







                                                                                                                          share|improve this answer














                                                                                                                          share|improve this answer



                                                                                                                          share|improve this answer








                                                                                                                          edited 14 hours ago

























                                                                                                                          answered 14 hours ago









                                                                                                                          Kevin CruijssenKevin Cruijssen

                                                                                                                          50.7k7 gold badges85 silver badges247 bronze badges




                                                                                                                          50.7k7 gold badges85 silver badges247 bronze badges
























                                                                                                                              0














                                                                                                                              $begingroup$


                                                                                                                              Jelly, 8 6 bytes (chunk length 3)



                                                                                                                              Ḥ;²3ị 


                                                                                                                              Try it online!



                                                                                                                              Doubled






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$



















                                                                                                                                0














                                                                                                                                $begingroup$


                                                                                                                                Jelly, 8 6 bytes (chunk length 3)



                                                                                                                                Ḥ;²3ị 


                                                                                                                                Try it online!



                                                                                                                                Doubled






                                                                                                                                share|improve this answer











                                                                                                                                $endgroup$

















                                                                                                                                  0














                                                                                                                                  0










                                                                                                                                  0







                                                                                                                                  $begingroup$


                                                                                                                                  Jelly, 8 6 bytes (chunk length 3)



                                                                                                                                  Ḥ;²3ị 


                                                                                                                                  Try it online!



                                                                                                                                  Doubled






                                                                                                                                  share|improve this answer











                                                                                                                                  $endgroup$




                                                                                                                                  Jelly, 8 6 bytes (chunk length 3)



                                                                                                                                  Ḥ;²3ị 


                                                                                                                                  Try it online!



                                                                                                                                  Doubled







                                                                                                                                  share|improve this answer














                                                                                                                                  share|improve this answer



                                                                                                                                  share|improve this answer








                                                                                                                                  edited 7 hours ago

























                                                                                                                                  answered 8 hours ago









                                                                                                                                  Nick KennedyNick Kennedy

                                                                                                                                  6,4851 gold badge9 silver badges15 bronze badges




                                                                                                                                  6,4851 gold badge9 silver badges15 bronze badges
























                                                                                                                                      0














                                                                                                                                      $begingroup$


                                                                                                                                      J, 17 bytes



                                                                                                                                      *:@[`(+:@[)@.(=~)


                                                                                                                                      Try it online!



                                                                                                                                      Doubled version: Try it online!



                                                                                                                                      In the single version, we have a single verb which uses Agenda @. to do the if... then logic: If the argument is equal to itself =~, then take the argument and double it (+:@[).



                                                                                                                                      However, when we double the code, we get a J hook. Call the verb f and the input y. Then the hook f f executes like this:



                                                                                                                                      y f (f y)


                                                                                                                                      Which means that now the original input is the left arg, and the right arg is the doubled input. Since these will not be equal, =~ will return false this time, and now we'll execute the other fork of the Agenda, ie, *:@[, which means "square the left arg." And since that's the original input, we have what we need.






                                                                                                                                      share|improve this answer









                                                                                                                                      $endgroup$



















                                                                                                                                        0














                                                                                                                                        $begingroup$


                                                                                                                                        J, 17 bytes



                                                                                                                                        *:@[`(+:@[)@.(=~)


                                                                                                                                        Try it online!



                                                                                                                                        Doubled version: Try it online!



                                                                                                                                        In the single version, we have a single verb which uses Agenda @. to do the if... then logic: If the argument is equal to itself =~, then take the argument and double it (+:@[).



                                                                                                                                        However, when we double the code, we get a J hook. Call the verb f and the input y. Then the hook f f executes like this:



                                                                                                                                        y f (f y)


                                                                                                                                        Which means that now the original input is the left arg, and the right arg is the doubled input. Since these will not be equal, =~ will return false this time, and now we'll execute the other fork of the Agenda, ie, *:@[, which means "square the left arg." And since that's the original input, we have what we need.






                                                                                                                                        share|improve this answer









                                                                                                                                        $endgroup$

















                                                                                                                                          0














                                                                                                                                          0










                                                                                                                                          0







                                                                                                                                          $begingroup$


                                                                                                                                          J, 17 bytes



                                                                                                                                          *:@[`(+:@[)@.(=~)


                                                                                                                                          Try it online!



                                                                                                                                          Doubled version: Try it online!



                                                                                                                                          In the single version, we have a single verb which uses Agenda @. to do the if... then logic: If the argument is equal to itself =~, then take the argument and double it (+:@[).



                                                                                                                                          However, when we double the code, we get a J hook. Call the verb f and the input y. Then the hook f f executes like this:



                                                                                                                                          y f (f y)


                                                                                                                                          Which means that now the original input is the left arg, and the right arg is the doubled input. Since these will not be equal, =~ will return false this time, and now we'll execute the other fork of the Agenda, ie, *:@[, which means "square the left arg." And since that's the original input, we have what we need.






                                                                                                                                          share|improve this answer









                                                                                                                                          $endgroup$




                                                                                                                                          J, 17 bytes



                                                                                                                                          *:@[`(+:@[)@.(=~)


                                                                                                                                          Try it online!



                                                                                                                                          Doubled version: Try it online!



                                                                                                                                          In the single version, we have a single verb which uses Agenda @. to do the if... then logic: If the argument is equal to itself =~, then take the argument and double it (+:@[).



                                                                                                                                          However, when we double the code, we get a J hook. Call the verb f and the input y. Then the hook f f executes like this:



                                                                                                                                          y f (f y)


                                                                                                                                          Which means that now the original input is the left arg, and the right arg is the doubled input. Since these will not be equal, =~ will return false this time, and now we'll execute the other fork of the Agenda, ie, *:@[, which means "square the left arg." And since that's the original input, we have what we need.







                                                                                                                                          share|improve this answer












                                                                                                                                          share|improve this answer



                                                                                                                                          share|improve this answer










                                                                                                                                          answered 1 hour ago









                                                                                                                                          JonahJonah

                                                                                                                                          4,7222 gold badges12 silver badges22 bronze badges




                                                                                                                                          4,7222 gold badges12 silver badges22 bronze badges































                                                                                                                                              draft saved

                                                                                                                                              draft discarded















































                                                                                                                                              If this is an answer to a challenge…



                                                                                                                                              • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                              • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                                Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                              • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                                                                                                              More generally…



                                                                                                                                              • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                              • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                                                                                                              draft saved


                                                                                                                                              draft discarded














                                                                                                                                              StackExchange.ready(
                                                                                                                                              function ()
                                                                                                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f191580%2fdouble-it-your-way%23new-answer', 'question_page');

                                                                                                                                              );

                                                                                                                                              Post as a guest















                                                                                                                                              Required, but never shown





















































                                                                                                                                              Required, but never shown














                                                                                                                                              Required, but never shown












                                                                                                                                              Required, but never shown







                                                                                                                                              Required, but never shown

































                                                                                                                                              Required, but never shown














                                                                                                                                              Required, but never shown












                                                                                                                                              Required, but never shown







                                                                                                                                              Required, but never shown







                                                                                                                                              Popular posts from this blog

                                                                                                                                              Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                                                                                                                              Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                                                                                                                              Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367