Couch 2048: How much more till 2048?











up vote
15
down vote

favorite












I have just tried a game called Couch 2048.

(Note: You should have a look to better understand this question.)

Since it wasn't very exciting for me, I've been asking myself 'How much more till 2048!?'

That inspired me to post a challenge, because calculating this in not as easy as I thought.



Your goal:

Given a list of balls on the sofa, you have to output how many balls with a value of 2 have to fall from the sky so that one can win the game (by reaching the 2048 ball).




  • Assume the input is valid.

  • Assume the player won't drop any balls.

  • Assume the balls which fall from the sky always have a value of 2, as I've said.

  • Valid output examples: 3, "4", [5], ["6"]


Edit:

I should clarify something:

- You have to print the smallest amount of 2s needed.



Test cases:
[2048] -> 0 You've already won
[1024,1024] -> 0 You don't need any more balls to win
[1024,512,256,128,64,32,16,8,4,2] -> 1 One ball required to 'activate the chain'
[512] -> 768
[512,2] -> 767
[4,16,64] -> 982



Notes:

I'm not a native speaker - Tell me if you spotted a typo or some non-grammatical text.

If something's unclear, ask in comments.










share|improve this question









New contributor




micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • why [4,16,64] -> 22?
    – l4m2
    yesterday






  • 3




    Welcome to PPCG. It looks like this challenge is: add all the elements in the array, subtract from 2048 and divide by 2 - if so, you might want to double check the last test case - if not, please use it as an example to explain why the output isn't 982.
    – Shaggy
    yesterday






  • 1




    @Shaggy thx for noticing a silly mistake
    – micnap
    yesterday










  • Hi there. I took the liberty of fixing some grammar/spelling mistakes. I saw your note at the bottom. :) You can take a look at the changed I did, and if anything is incorrect, feel free to revert or edit again. Regardless of the grammar/spelling, it's a nice first challenge, so +1 from me. Enjoy your stay!
    – Kevin Cruijssen
    yesterday






  • 2




    Woah, I haven't thought my first challenge will have 7 answers and 2 upvotes in the first hour! And I reached to ~28 people!
    – micnap
    yesterday















up vote
15
down vote

favorite












I have just tried a game called Couch 2048.

(Note: You should have a look to better understand this question.)

Since it wasn't very exciting for me, I've been asking myself 'How much more till 2048!?'

That inspired me to post a challenge, because calculating this in not as easy as I thought.



Your goal:

Given a list of balls on the sofa, you have to output how many balls with a value of 2 have to fall from the sky so that one can win the game (by reaching the 2048 ball).




  • Assume the input is valid.

  • Assume the player won't drop any balls.

  • Assume the balls which fall from the sky always have a value of 2, as I've said.

  • Valid output examples: 3, "4", [5], ["6"]


Edit:

I should clarify something:

- You have to print the smallest amount of 2s needed.



Test cases:
[2048] -> 0 You've already won
[1024,1024] -> 0 You don't need any more balls to win
[1024,512,256,128,64,32,16,8,4,2] -> 1 One ball required to 'activate the chain'
[512] -> 768
[512,2] -> 767
[4,16,64] -> 982



Notes:

I'm not a native speaker - Tell me if you spotted a typo or some non-grammatical text.

If something's unclear, ask in comments.










share|improve this question









New contributor




micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • why [4,16,64] -> 22?
    – l4m2
    yesterday






  • 3




    Welcome to PPCG. It looks like this challenge is: add all the elements in the array, subtract from 2048 and divide by 2 - if so, you might want to double check the last test case - if not, please use it as an example to explain why the output isn't 982.
    – Shaggy
    yesterday






  • 1




    @Shaggy thx for noticing a silly mistake
    – micnap
    yesterday










  • Hi there. I took the liberty of fixing some grammar/spelling mistakes. I saw your note at the bottom. :) You can take a look at the changed I did, and if anything is incorrect, feel free to revert or edit again. Regardless of the grammar/spelling, it's a nice first challenge, so +1 from me. Enjoy your stay!
    – Kevin Cruijssen
    yesterday






  • 2




    Woah, I haven't thought my first challenge will have 7 answers and 2 upvotes in the first hour! And I reached to ~28 people!
    – micnap
    yesterday













up vote
15
down vote

favorite









up vote
15
down vote

favorite











I have just tried a game called Couch 2048.

(Note: You should have a look to better understand this question.)

Since it wasn't very exciting for me, I've been asking myself 'How much more till 2048!?'

That inspired me to post a challenge, because calculating this in not as easy as I thought.



Your goal:

Given a list of balls on the sofa, you have to output how many balls with a value of 2 have to fall from the sky so that one can win the game (by reaching the 2048 ball).




  • Assume the input is valid.

  • Assume the player won't drop any balls.

  • Assume the balls which fall from the sky always have a value of 2, as I've said.

  • Valid output examples: 3, "4", [5], ["6"]


Edit:

I should clarify something:

- You have to print the smallest amount of 2s needed.



Test cases:
[2048] -> 0 You've already won
[1024,1024] -> 0 You don't need any more balls to win
[1024,512,256,128,64,32,16,8,4,2] -> 1 One ball required to 'activate the chain'
[512] -> 768
[512,2] -> 767
[4,16,64] -> 982



Notes:

I'm not a native speaker - Tell me if you spotted a typo or some non-grammatical text.

If something's unclear, ask in comments.










share|improve this question









New contributor




micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have just tried a game called Couch 2048.

(Note: You should have a look to better understand this question.)

Since it wasn't very exciting for me, I've been asking myself 'How much more till 2048!?'

That inspired me to post a challenge, because calculating this in not as easy as I thought.



Your goal:

Given a list of balls on the sofa, you have to output how many balls with a value of 2 have to fall from the sky so that one can win the game (by reaching the 2048 ball).




  • Assume the input is valid.

  • Assume the player won't drop any balls.

  • Assume the balls which fall from the sky always have a value of 2, as I've said.

  • Valid output examples: 3, "4", [5], ["6"]


Edit:

I should clarify something:

- You have to print the smallest amount of 2s needed.



Test cases:
[2048] -> 0 You've already won
[1024,1024] -> 0 You don't need any more balls to win
[1024,512,256,128,64,32,16,8,4,2] -> 1 One ball required to 'activate the chain'
[512] -> 768
[512,2] -> 767
[4,16,64] -> 982



Notes:

I'm not a native speaker - Tell me if you spotted a typo or some non-grammatical text.

If something's unclear, ask in comments.







code-golf






share|improve this question









New contributor




micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday





















New contributor




micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









micnap

7916




7916




New contributor




micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






micnap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • why [4,16,64] -> 22?
    – l4m2
    yesterday






  • 3




    Welcome to PPCG. It looks like this challenge is: add all the elements in the array, subtract from 2048 and divide by 2 - if so, you might want to double check the last test case - if not, please use it as an example to explain why the output isn't 982.
    – Shaggy
    yesterday






  • 1




    @Shaggy thx for noticing a silly mistake
    – micnap
    yesterday










  • Hi there. I took the liberty of fixing some grammar/spelling mistakes. I saw your note at the bottom. :) You can take a look at the changed I did, and if anything is incorrect, feel free to revert or edit again. Regardless of the grammar/spelling, it's a nice first challenge, so +1 from me. Enjoy your stay!
    – Kevin Cruijssen
    yesterday






  • 2




    Woah, I haven't thought my first challenge will have 7 answers and 2 upvotes in the first hour! And I reached to ~28 people!
    – micnap
    yesterday


















  • why [4,16,64] -> 22?
    – l4m2
    yesterday






  • 3




    Welcome to PPCG. It looks like this challenge is: add all the elements in the array, subtract from 2048 and divide by 2 - if so, you might want to double check the last test case - if not, please use it as an example to explain why the output isn't 982.
    – Shaggy
    yesterday






  • 1




    @Shaggy thx for noticing a silly mistake
    – micnap
    yesterday










  • Hi there. I took the liberty of fixing some grammar/spelling mistakes. I saw your note at the bottom. :) You can take a look at the changed I did, and if anything is incorrect, feel free to revert or edit again. Regardless of the grammar/spelling, it's a nice first challenge, so +1 from me. Enjoy your stay!
    – Kevin Cruijssen
    yesterday






  • 2




    Woah, I haven't thought my first challenge will have 7 answers and 2 upvotes in the first hour! And I reached to ~28 people!
    – micnap
    yesterday
















why [4,16,64] -> 22?
– l4m2
yesterday




why [4,16,64] -> 22?
– l4m2
yesterday




3




3




Welcome to PPCG. It looks like this challenge is: add all the elements in the array, subtract from 2048 and divide by 2 - if so, you might want to double check the last test case - if not, please use it as an example to explain why the output isn't 982.
– Shaggy
yesterday




Welcome to PPCG. It looks like this challenge is: add all the elements in the array, subtract from 2048 and divide by 2 - if so, you might want to double check the last test case - if not, please use it as an example to explain why the output isn't 982.
– Shaggy
yesterday




1




1




@Shaggy thx for noticing a silly mistake
– micnap
yesterday




@Shaggy thx for noticing a silly mistake
– micnap
yesterday












Hi there. I took the liberty of fixing some grammar/spelling mistakes. I saw your note at the bottom. :) You can take a look at the changed I did, and if anything is incorrect, feel free to revert or edit again. Regardless of the grammar/spelling, it's a nice first challenge, so +1 from me. Enjoy your stay!
– Kevin Cruijssen
yesterday




Hi there. I took the liberty of fixing some grammar/spelling mistakes. I saw your note at the bottom. :) You can take a look at the changed I did, and if anything is incorrect, feel free to revert or edit again. Regardless of the grammar/spelling, it's a nice first challenge, so +1 from me. Enjoy your stay!
– Kevin Cruijssen
yesterday




2




2




Woah, I haven't thought my first challenge will have 7 answers and 2 upvotes in the first hour! And I reached to ~28 people!
– micnap
yesterday




Woah, I haven't thought my first challenge will have 7 answers and 2 upvotes in the first hour! And I reached to ~28 people!
– micnap
yesterday










24 Answers
24






active

oldest

votes

















up vote
9
down vote













Java 8, 17 bytes





s->1024-s.sum()/2


Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



Try it online.



Explanation:



s->           // Method with IntStream parameter and int return-type
1024- // Return 1024, minus:
s.sum() // The sum of the input-IntStream
/2 // Divided by 2





share|improve this answer

















  • 6




    That feeling when Java is beating both python(because lambda syntax) and javascript(because sum)
    – Quintec
    yesterday


















up vote
7
down vote














Brain-Flak, 72 bytes



({{}})({<({}[()()])>()}{})([{}]((((((((()()()()){}){}){}){}){}){}){}){})


Try it online!



({{}})                     # Sum entire stack
( ) # Push:
{< >()}{} # The number of times you can...
({}[()()]) # Subtract 2 before reaching 0

([{}] ) # Subtract that from...
((((((((()()()()){}){}){}){}){}){}){}){} # 1024





share|improve this answer





















  • Thank you! I'm interested in learning Brain-Flak and your explanation was useful.
    – Galen Ivanov
    8 hours ago


















up vote
6
down vote














Python 2, 22 bytes





lambda x:4**5-sum(x)/2


Y'know, I just realized that 4**5 is the same length as 1024.



Try it online!






share|improve this answer




























    up vote
    5
    down vote














    05AB1E, 5 bytes



    O;žBα


    Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



    Try it online or verify all test cases.



    Explanation:





    O        # Sum of the (implicit) input-list
    ; # Halved
    žB # Push 1024
    α # Absolute difference between the two (and output implicitly)





    share|improve this answer




























      up vote
      5
      down vote














      MathGolf, 6 5 bytes



      Σc/◘+


      First MathGolf answer. :)



      Try it online or verify all test cases.



      Explanation:





      Σ         # Sum of the (implicit) input-list
      c/ # Divide it by -2
      ◘+ # Add 1024 to it (and output implicitly)





      share|improve this answer






























        up vote
        3
        down vote














        APL (Dyalog Unicode), 10 bytes





        2÷⍨2048-+/


        Try it online!






        share|improve this answer




























          up vote
          3
          down vote














          JavaScript (Node.js), 25 bytes



          Based on @Shaggys' comment and answer



          -3 bytes from @Arnauld =D





          _=>1024-eval(_.join`+`)/2


          Try it online!






          share|improve this answer






























            up vote
            2
            down vote














            Ruby, 17 bytes





            ->l{1024-l.sum/2}


            Try it online!






            share|improve this answer




























              up vote
              1
              down vote













              JavaScript, 28 bytes



              a=>a.map(n=>x-=n/2,x=1024)|x


              Try it online






              share|improve this answer




























                up vote
                1
                down vote














                J, 10 bytes



                2048-:@-+/


                Try it online!



                Alternative:




                J, 10 bytes



                1024-1#.-:


                Try it online!






                share|improve this answer






























                  up vote
                  1
                  down vote














                  Jelly, 7 6 bytes



                  HSạ⁽¡ç


                  Try it online!



                  Explanation:



                  HSạ⁽¡ç    Example input: [4,16,64]
                  H Halve input. [2, 8, 32]
                  S Sum. 42
                  ⁽¡ç Number 1024.
                  ạ Difference. 982


                  -1 byte by using a base-250 number






                  share|improve this answer






























                    up vote
                    1
                    down vote














                    Catholicon, 5 bytes



                    -`L̇½Ṗ


                    Explanation:



                    -      subtract
                    `L̇ 1024
                    from
                    ½ half of the
                    Ṗ sum [of the input]





                    share|improve this answer

















                    • 1




                      Is that a new golfing language I smell? :)
                      – ETHproductions
                      18 hours ago






                    • 1




                      +1 for the new language. Another one to learn </sigh>
                      – ElPedro
                      18 hours ago


















                    up vote
                    1
                    down vote













                    TI-Basic, 8 bytes



                    4^5-.5sum(Ans





                    share|improve this answer




























                      up vote
                      1
                      down vote













                      Japt, 7 6 bytes



                      xz nH²


                      Try it or verify all test cases



                       z         :(Floor) divide each by 2
                      x :Reduce by addition
                      n :Subtract from
                      H : 32
                      ² : Squared





                      share|improve this answer






























                        up vote
                        0
                        down vote














                        JavaScript (Node.js), 33 bytes





                        a=>!a.map(n=>x-=n/2,x=1024)>x?0:x


                        Try it online!



                        Why you don't do on [1024,1024,1024]?






                        share|improve this answer




























                          up vote
                          0
                          down vote














                          R, 17 bytes





                          4^5-sum(scan())/2


                          Try it online!






                          share|improve this answer




























                            up vote
                            0
                            down vote














                            TeaScript, 11 bytes





                            4p5)-(xx)/2


                            Try it online!






                            share|improve this answer




























                              up vote
                              0
                              down vote














                              Stax, 6 bytes



                              ë3i─♠÷


                              Run and debug it






                              share|improve this answer




























                                up vote
                                0
                                down vote













                                perl -aE, 27 bytes



                                $"=$:;say eval"(2048-@F)/2"


                                This reads a line with numbers (whitespace separated) from STDIN, and writes the answer to STDOUT.



                                What it does is subtract all the numbers from the input from 2048, and it divides the remainder by 2. The -a switch puts the in the array @F (one number per element). If we interpolate an array into a string (which is what we are doing here), perl puts the value of $" between the elements. The little used variable $: is be default n-; and since white space between tokens is ignored, the result is subtracting all the numbers from 2048. The eval does the calculation.






                                share|improve this answer




























                                  up vote
                                  0
                                  down vote














                                  Perl 6, 12 bytes





                                  1024-*.sum/2


                                  Try it online!



                                  Anonymous Whatever lambda that takes a list and returns a number.






                                  share|improve this answer




























                                    up vote
                                    0
                                    down vote













                                    AWK, 26 bytes



                                    {s+=$1}END{print 1024-s/2}


                                    Input numbers are separated by newlines (i.e. one per line)






                                    share|improve this answer




























                                      up vote
                                      0
                                      down vote













                                      Neim, 6 bytes



                                      Pretty new to Neim but got it working



                                      𝐬ᚺςᚫᛦ𝕤


                                      Explanation:



                                        𝐬         : Sum input
                                      ᚺ : Divide by 2 (stack now [input summed and divided by 2])
                                      ς : Variable set to 16 pushed to stack
                                      ᚫ : Multiply by 2
                                      ᛦ : Square (stack now [input summed and divided by 2, 1024])
                                      𝕤 : Subtract then absolute


                                      Try it online!






                                      share|improve this answer




























                                        up vote
                                        0
                                        down vote













                                        JAVA, 30 bytes



                                        2048-IntStream.of(a).sum()/2;





                                        share|improve this answer








                                        New contributor




                                        isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                        Check out our Code of Conduct.

























                                          up vote
                                          0
                                          down vote














                                          RAD, 10 bytes



                                          1024-+/ω÷2


                                          Try it online!






                                          share|improve this answer





















                                            Your Answer





                                            StackExchange.ifUsing("editor", function () {
                                            return StackExchange.using("mathjaxEditing", function () {
                                            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                                            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                                            });
                                            });
                                            }, "mathjax-editing");

                                            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',
                                            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/3.0/"u003ecc by-sa 3.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
                                            });


                                            }
                                            });






                                            micnap is a new contributor. Be nice, and check out our Code of Conduct.










                                             

                                            draft saved


                                            draft discarded


















                                            StackExchange.ready(
                                            function () {
                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175765%2fcouch-2048-how-much-more-till-2048%23new-answer', 'question_page');
                                            }
                                            );

                                            Post as a guest
































                                            24 Answers
                                            24






                                            active

                                            oldest

                                            votes








                                            24 Answers
                                            24






                                            active

                                            oldest

                                            votes









                                            active

                                            oldest

                                            votes






                                            active

                                            oldest

                                            votes








                                            up vote
                                            9
                                            down vote













                                            Java 8, 17 bytes





                                            s->1024-s.sum()/2


                                            Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



                                            Try it online.



                                            Explanation:



                                            s->           // Method with IntStream parameter and int return-type
                                            1024- // Return 1024, minus:
                                            s.sum() // The sum of the input-IntStream
                                            /2 // Divided by 2





                                            share|improve this answer

















                                            • 6




                                              That feeling when Java is beating both python(because lambda syntax) and javascript(because sum)
                                              – Quintec
                                              yesterday















                                            up vote
                                            9
                                            down vote













                                            Java 8, 17 bytes





                                            s->1024-s.sum()/2


                                            Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



                                            Try it online.



                                            Explanation:



                                            s->           // Method with IntStream parameter and int return-type
                                            1024- // Return 1024, minus:
                                            s.sum() // The sum of the input-IntStream
                                            /2 // Divided by 2





                                            share|improve this answer

















                                            • 6




                                              That feeling when Java is beating both python(because lambda syntax) and javascript(because sum)
                                              – Quintec
                                              yesterday













                                            up vote
                                            9
                                            down vote










                                            up vote
                                            9
                                            down vote









                                            Java 8, 17 bytes





                                            s->1024-s.sum()/2


                                            Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



                                            Try it online.



                                            Explanation:



                                            s->           // Method with IntStream parameter and int return-type
                                            1024- // Return 1024, minus:
                                            s.sum() // The sum of the input-IntStream
                                            /2 // Divided by 2





                                            share|improve this answer












                                            Java 8, 17 bytes





                                            s->1024-s.sum()/2


                                            Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



                                            Try it online.



                                            Explanation:



                                            s->           // Method with IntStream parameter and int return-type
                                            1024- // Return 1024, minus:
                                            s.sum() // The sum of the input-IntStream
                                            /2 // Divided by 2






                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered yesterday









                                            Kevin Cruijssen

                                            33.5k554178




                                            33.5k554178








                                            • 6




                                              That feeling when Java is beating both python(because lambda syntax) and javascript(because sum)
                                              – Quintec
                                              yesterday














                                            • 6




                                              That feeling when Java is beating both python(because lambda syntax) and javascript(because sum)
                                              – Quintec
                                              yesterday








                                            6




                                            6




                                            That feeling when Java is beating both python(because lambda syntax) and javascript(because sum)
                                            – Quintec
                                            yesterday




                                            That feeling when Java is beating both python(because lambda syntax) and javascript(because sum)
                                            – Quintec
                                            yesterday










                                            up vote
                                            7
                                            down vote














                                            Brain-Flak, 72 bytes



                                            ({{}})({<({}[()()])>()}{})([{}]((((((((()()()()){}){}){}){}){}){}){}){})


                                            Try it online!



                                            ({{}})                     # Sum entire stack
                                            ( ) # Push:
                                            {< >()}{} # The number of times you can...
                                            ({}[()()]) # Subtract 2 before reaching 0

                                            ([{}] ) # Subtract that from...
                                            ((((((((()()()()){}){}){}){}){}){}){}){} # 1024





                                            share|improve this answer





















                                            • Thank you! I'm interested in learning Brain-Flak and your explanation was useful.
                                              – Galen Ivanov
                                              8 hours ago















                                            up vote
                                            7
                                            down vote














                                            Brain-Flak, 72 bytes



                                            ({{}})({<({}[()()])>()}{})([{}]((((((((()()()()){}){}){}){}){}){}){}){})


                                            Try it online!



                                            ({{}})                     # Sum entire stack
                                            ( ) # Push:
                                            {< >()}{} # The number of times you can...
                                            ({}[()()]) # Subtract 2 before reaching 0

                                            ([{}] ) # Subtract that from...
                                            ((((((((()()()()){}){}){}){}){}){}){}){} # 1024





                                            share|improve this answer





















                                            • Thank you! I'm interested in learning Brain-Flak and your explanation was useful.
                                              – Galen Ivanov
                                              8 hours ago













                                            up vote
                                            7
                                            down vote










                                            up vote
                                            7
                                            down vote










                                            Brain-Flak, 72 bytes



                                            ({{}})({<({}[()()])>()}{})([{}]((((((((()()()()){}){}){}){}){}){}){}){})


                                            Try it online!



                                            ({{}})                     # Sum entire stack
                                            ( ) # Push:
                                            {< >()}{} # The number of times you can...
                                            ({}[()()]) # Subtract 2 before reaching 0

                                            ([{}] ) # Subtract that from...
                                            ((((((((()()()()){}){}){}){}){}){}){}){} # 1024





                                            share|improve this answer













                                            Brain-Flak, 72 bytes



                                            ({{}})({<({}[()()])>()}{})([{}]((((((((()()()()){}){}){}){}){}){}){}){})


                                            Try it online!



                                            ({{}})                     # Sum entire stack
                                            ( ) # Push:
                                            {< >()}{} # The number of times you can...
                                            ({}[()()]) # Subtract 2 before reaching 0

                                            ([{}] ) # Subtract that from...
                                            ((((((((()()()()){}){}){}){}){}){}){}){} # 1024






                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered yesterday









                                            Riley

                                            10.8k11448




                                            10.8k11448












                                            • Thank you! I'm interested in learning Brain-Flak and your explanation was useful.
                                              – Galen Ivanov
                                              8 hours ago


















                                            • Thank you! I'm interested in learning Brain-Flak and your explanation was useful.
                                              – Galen Ivanov
                                              8 hours ago
















                                            Thank you! I'm interested in learning Brain-Flak and your explanation was useful.
                                            – Galen Ivanov
                                            8 hours ago




                                            Thank you! I'm interested in learning Brain-Flak and your explanation was useful.
                                            – Galen Ivanov
                                            8 hours ago










                                            up vote
                                            6
                                            down vote














                                            Python 2, 22 bytes





                                            lambda x:4**5-sum(x)/2


                                            Y'know, I just realized that 4**5 is the same length as 1024.



                                            Try it online!






                                            share|improve this answer

























                                              up vote
                                              6
                                              down vote














                                              Python 2, 22 bytes





                                              lambda x:4**5-sum(x)/2


                                              Y'know, I just realized that 4**5 is the same length as 1024.



                                              Try it online!






                                              share|improve this answer























                                                up vote
                                                6
                                                down vote










                                                up vote
                                                6
                                                down vote










                                                Python 2, 22 bytes





                                                lambda x:4**5-sum(x)/2


                                                Y'know, I just realized that 4**5 is the same length as 1024.



                                                Try it online!






                                                share|improve this answer













                                                Python 2, 22 bytes





                                                lambda x:4**5-sum(x)/2


                                                Y'know, I just realized that 4**5 is the same length as 1024.



                                                Try it online!







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered yesterday









                                                Quintec

                                                1,195518




                                                1,195518






















                                                    up vote
                                                    5
                                                    down vote














                                                    05AB1E, 5 bytes



                                                    O;žBα


                                                    Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



                                                    Try it online or verify all test cases.



                                                    Explanation:





                                                    O        # Sum of the (implicit) input-list
                                                    ; # Halved
                                                    žB # Push 1024
                                                    α # Absolute difference between the two (and output implicitly)





                                                    share|improve this answer

























                                                      up vote
                                                      5
                                                      down vote














                                                      05AB1E, 5 bytes



                                                      O;žBα


                                                      Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



                                                      Try it online or verify all test cases.



                                                      Explanation:





                                                      O        # Sum of the (implicit) input-list
                                                      ; # Halved
                                                      žB # Push 1024
                                                      α # Absolute difference between the two (and output implicitly)





                                                      share|improve this answer























                                                        up vote
                                                        5
                                                        down vote










                                                        up vote
                                                        5
                                                        down vote










                                                        05AB1E, 5 bytes



                                                        O;žBα


                                                        Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



                                                        Try it online or verify all test cases.



                                                        Explanation:





                                                        O        # Sum of the (implicit) input-list
                                                        ; # Halved
                                                        žB # Push 1024
                                                        α # Absolute difference between the two (and output implicitly)





                                                        share|improve this answer













                                                        05AB1E, 5 bytes



                                                        O;žBα


                                                        Port of @LuisFelipeDeJesusMunoz' JavaScript answer.



                                                        Try it online or verify all test cases.



                                                        Explanation:





                                                        O        # Sum of the (implicit) input-list
                                                        ; # Halved
                                                        žB # Push 1024
                                                        α # Absolute difference between the two (and output implicitly)






                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered yesterday









                                                        Kevin Cruijssen

                                                        33.5k554178




                                                        33.5k554178






















                                                            up vote
                                                            5
                                                            down vote














                                                            MathGolf, 6 5 bytes



                                                            Σc/◘+


                                                            First MathGolf answer. :)



                                                            Try it online or verify all test cases.



                                                            Explanation:





                                                            Σ         # Sum of the (implicit) input-list
                                                            c/ # Divide it by -2
                                                            ◘+ # Add 1024 to it (and output implicitly)





                                                            share|improve this answer



























                                                              up vote
                                                              5
                                                              down vote














                                                              MathGolf, 6 5 bytes



                                                              Σc/◘+


                                                              First MathGolf answer. :)



                                                              Try it online or verify all test cases.



                                                              Explanation:





                                                              Σ         # Sum of the (implicit) input-list
                                                              c/ # Divide it by -2
                                                              ◘+ # Add 1024 to it (and output implicitly)





                                                              share|improve this answer

























                                                                up vote
                                                                5
                                                                down vote










                                                                up vote
                                                                5
                                                                down vote










                                                                MathGolf, 6 5 bytes



                                                                Σc/◘+


                                                                First MathGolf answer. :)



                                                                Try it online or verify all test cases.



                                                                Explanation:





                                                                Σ         # Sum of the (implicit) input-list
                                                                c/ # Divide it by -2
                                                                ◘+ # Add 1024 to it (and output implicitly)





                                                                share|improve this answer















                                                                MathGolf, 6 5 bytes



                                                                Σc/◘+


                                                                First MathGolf answer. :)



                                                                Try it online or verify all test cases.



                                                                Explanation:





                                                                Σ         # Sum of the (implicit) input-list
                                                                c/ # Divide it by -2
                                                                ◘+ # Add 1024 to it (and output implicitly)






                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited yesterday

























                                                                answered yesterday









                                                                Kevin Cruijssen

                                                                33.5k554178




                                                                33.5k554178






















                                                                    up vote
                                                                    3
                                                                    down vote














                                                                    APL (Dyalog Unicode), 10 bytes





                                                                    2÷⍨2048-+/


                                                                    Try it online!






                                                                    share|improve this answer

























                                                                      up vote
                                                                      3
                                                                      down vote














                                                                      APL (Dyalog Unicode), 10 bytes





                                                                      2÷⍨2048-+/


                                                                      Try it online!






                                                                      share|improve this answer























                                                                        up vote
                                                                        3
                                                                        down vote










                                                                        up vote
                                                                        3
                                                                        down vote










                                                                        APL (Dyalog Unicode), 10 bytes





                                                                        2÷⍨2048-+/


                                                                        Try it online!






                                                                        share|improve this answer













                                                                        APL (Dyalog Unicode), 10 bytes





                                                                        2÷⍨2048-+/


                                                                        Try it online!







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered yesterday









                                                                        J. Sallé

                                                                        1,753322




                                                                        1,753322






















                                                                            up vote
                                                                            3
                                                                            down vote














                                                                            JavaScript (Node.js), 25 bytes



                                                                            Based on @Shaggys' comment and answer



                                                                            -3 bytes from @Arnauld =D





                                                                            _=>1024-eval(_.join`+`)/2


                                                                            Try it online!






                                                                            share|improve this answer



























                                                                              up vote
                                                                              3
                                                                              down vote














                                                                              JavaScript (Node.js), 25 bytes



                                                                              Based on @Shaggys' comment and answer



                                                                              -3 bytes from @Arnauld =D





                                                                              _=>1024-eval(_.join`+`)/2


                                                                              Try it online!






                                                                              share|improve this answer

























                                                                                up vote
                                                                                3
                                                                                down vote










                                                                                up vote
                                                                                3
                                                                                down vote










                                                                                JavaScript (Node.js), 25 bytes



                                                                                Based on @Shaggys' comment and answer



                                                                                -3 bytes from @Arnauld =D





                                                                                _=>1024-eval(_.join`+`)/2


                                                                                Try it online!






                                                                                share|improve this answer















                                                                                JavaScript (Node.js), 25 bytes



                                                                                Based on @Shaggys' comment and answer



                                                                                -3 bytes from @Arnauld =D





                                                                                _=>1024-eval(_.join`+`)/2


                                                                                Try it online!







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited yesterday

























                                                                                answered yesterday









                                                                                Luis felipe De jesus Munoz

                                                                                3,70211051




                                                                                3,70211051






















                                                                                    up vote
                                                                                    2
                                                                                    down vote














                                                                                    Ruby, 17 bytes





                                                                                    ->l{1024-l.sum/2}


                                                                                    Try it online!






                                                                                    share|improve this answer

























                                                                                      up vote
                                                                                      2
                                                                                      down vote














                                                                                      Ruby, 17 bytes





                                                                                      ->l{1024-l.sum/2}


                                                                                      Try it online!






                                                                                      share|improve this answer























                                                                                        up vote
                                                                                        2
                                                                                        down vote










                                                                                        up vote
                                                                                        2
                                                                                        down vote










                                                                                        Ruby, 17 bytes





                                                                                        ->l{1024-l.sum/2}


                                                                                        Try it online!






                                                                                        share|improve this answer













                                                                                        Ruby, 17 bytes





                                                                                        ->l{1024-l.sum/2}


                                                                                        Try it online!







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered yesterday









                                                                                        G B

                                                                                        7,4461327




                                                                                        7,4461327






















                                                                                            up vote
                                                                                            1
                                                                                            down vote













                                                                                            JavaScript, 28 bytes



                                                                                            a=>a.map(n=>x-=n/2,x=1024)|x


                                                                                            Try it online






                                                                                            share|improve this answer

























                                                                                              up vote
                                                                                              1
                                                                                              down vote













                                                                                              JavaScript, 28 bytes



                                                                                              a=>a.map(n=>x-=n/2,x=1024)|x


                                                                                              Try it online






                                                                                              share|improve this answer























                                                                                                up vote
                                                                                                1
                                                                                                down vote










                                                                                                up vote
                                                                                                1
                                                                                                down vote









                                                                                                JavaScript, 28 bytes



                                                                                                a=>a.map(n=>x-=n/2,x=1024)|x


                                                                                                Try it online






                                                                                                share|improve this answer












                                                                                                JavaScript, 28 bytes



                                                                                                a=>a.map(n=>x-=n/2,x=1024)|x


                                                                                                Try it online







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered yesterday









                                                                                                Shaggy

                                                                                                17.9k21663




                                                                                                17.9k21663






















                                                                                                    up vote
                                                                                                    1
                                                                                                    down vote














                                                                                                    J, 10 bytes



                                                                                                    2048-:@-+/


                                                                                                    Try it online!



                                                                                                    Alternative:




                                                                                                    J, 10 bytes



                                                                                                    1024-1#.-:


                                                                                                    Try it online!






                                                                                                    share|improve this answer



























                                                                                                      up vote
                                                                                                      1
                                                                                                      down vote














                                                                                                      J, 10 bytes



                                                                                                      2048-:@-+/


                                                                                                      Try it online!



                                                                                                      Alternative:




                                                                                                      J, 10 bytes



                                                                                                      1024-1#.-:


                                                                                                      Try it online!






                                                                                                      share|improve this answer

























                                                                                                        up vote
                                                                                                        1
                                                                                                        down vote










                                                                                                        up vote
                                                                                                        1
                                                                                                        down vote










                                                                                                        J, 10 bytes



                                                                                                        2048-:@-+/


                                                                                                        Try it online!



                                                                                                        Alternative:




                                                                                                        J, 10 bytes



                                                                                                        1024-1#.-:


                                                                                                        Try it online!






                                                                                                        share|improve this answer















                                                                                                        J, 10 bytes



                                                                                                        2048-:@-+/


                                                                                                        Try it online!



                                                                                                        Alternative:




                                                                                                        J, 10 bytes



                                                                                                        1024-1#.-:


                                                                                                        Try it online!







                                                                                                        share|improve this answer














                                                                                                        share|improve this answer



                                                                                                        share|improve this answer








                                                                                                        edited yesterday

























                                                                                                        answered yesterday









                                                                                                        Galen Ivanov

                                                                                                        5,76211032




                                                                                                        5,76211032






















                                                                                                            up vote
                                                                                                            1
                                                                                                            down vote














                                                                                                            Jelly, 7 6 bytes



                                                                                                            HSạ⁽¡ç


                                                                                                            Try it online!



                                                                                                            Explanation:



                                                                                                            HSạ⁽¡ç    Example input: [4,16,64]
                                                                                                            H Halve input. [2, 8, 32]
                                                                                                            S Sum. 42
                                                                                                            ⁽¡ç Number 1024.
                                                                                                            ạ Difference. 982


                                                                                                            -1 byte by using a base-250 number






                                                                                                            share|improve this answer



























                                                                                                              up vote
                                                                                                              1
                                                                                                              down vote














                                                                                                              Jelly, 7 6 bytes



                                                                                                              HSạ⁽¡ç


                                                                                                              Try it online!



                                                                                                              Explanation:



                                                                                                              HSạ⁽¡ç    Example input: [4,16,64]
                                                                                                              H Halve input. [2, 8, 32]
                                                                                                              S Sum. 42
                                                                                                              ⁽¡ç Number 1024.
                                                                                                              ạ Difference. 982


                                                                                                              -1 byte by using a base-250 number






                                                                                                              share|improve this answer

























                                                                                                                up vote
                                                                                                                1
                                                                                                                down vote










                                                                                                                up vote
                                                                                                                1
                                                                                                                down vote










                                                                                                                Jelly, 7 6 bytes



                                                                                                                HSạ⁽¡ç


                                                                                                                Try it online!



                                                                                                                Explanation:



                                                                                                                HSạ⁽¡ç    Example input: [4,16,64]
                                                                                                                H Halve input. [2, 8, 32]
                                                                                                                S Sum. 42
                                                                                                                ⁽¡ç Number 1024.
                                                                                                                ạ Difference. 982


                                                                                                                -1 byte by using a base-250 number






                                                                                                                share|improve this answer















                                                                                                                Jelly, 7 6 bytes



                                                                                                                HSạ⁽¡ç


                                                                                                                Try it online!



                                                                                                                Explanation:



                                                                                                                HSạ⁽¡ç    Example input: [4,16,64]
                                                                                                                H Halve input. [2, 8, 32]
                                                                                                                S Sum. 42
                                                                                                                ⁽¡ç Number 1024.
                                                                                                                ạ Difference. 982


                                                                                                                -1 byte by using a base-250 number







                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited yesterday

























                                                                                                                answered yesterday









                                                                                                                Comrade SparklePony

                                                                                                                3,23611252




                                                                                                                3,23611252






















                                                                                                                    up vote
                                                                                                                    1
                                                                                                                    down vote














                                                                                                                    Catholicon, 5 bytes



                                                                                                                    -`L̇½Ṗ


                                                                                                                    Explanation:



                                                                                                                    -      subtract
                                                                                                                    `L̇ 1024
                                                                                                                    from
                                                                                                                    ½ half of the
                                                                                                                    Ṗ sum [of the input]





                                                                                                                    share|improve this answer

















                                                                                                                    • 1




                                                                                                                      Is that a new golfing language I smell? :)
                                                                                                                      – ETHproductions
                                                                                                                      18 hours ago






                                                                                                                    • 1




                                                                                                                      +1 for the new language. Another one to learn </sigh>
                                                                                                                      – ElPedro
                                                                                                                      18 hours ago















                                                                                                                    up vote
                                                                                                                    1
                                                                                                                    down vote














                                                                                                                    Catholicon, 5 bytes



                                                                                                                    -`L̇½Ṗ


                                                                                                                    Explanation:



                                                                                                                    -      subtract
                                                                                                                    `L̇ 1024
                                                                                                                    from
                                                                                                                    ½ half of the
                                                                                                                    Ṗ sum [of the input]





                                                                                                                    share|improve this answer

















                                                                                                                    • 1




                                                                                                                      Is that a new golfing language I smell? :)
                                                                                                                      – ETHproductions
                                                                                                                      18 hours ago






                                                                                                                    • 1




                                                                                                                      +1 for the new language. Another one to learn </sigh>
                                                                                                                      – ElPedro
                                                                                                                      18 hours ago













                                                                                                                    up vote
                                                                                                                    1
                                                                                                                    down vote










                                                                                                                    up vote
                                                                                                                    1
                                                                                                                    down vote










                                                                                                                    Catholicon, 5 bytes



                                                                                                                    -`L̇½Ṗ


                                                                                                                    Explanation:



                                                                                                                    -      subtract
                                                                                                                    `L̇ 1024
                                                                                                                    from
                                                                                                                    ½ half of the
                                                                                                                    Ṗ sum [of the input]





                                                                                                                    share|improve this answer













                                                                                                                    Catholicon, 5 bytes



                                                                                                                    -`L̇½Ṗ


                                                                                                                    Explanation:



                                                                                                                    -      subtract
                                                                                                                    `L̇ 1024
                                                                                                                    from
                                                                                                                    ½ half of the
                                                                                                                    Ṗ sum [of the input]






                                                                                                                    share|improve this answer












                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer










                                                                                                                    answered yesterday









                                                                                                                    Okx

                                                                                                                    12.3k27100




                                                                                                                    12.3k27100








                                                                                                                    • 1




                                                                                                                      Is that a new golfing language I smell? :)
                                                                                                                      – ETHproductions
                                                                                                                      18 hours ago






                                                                                                                    • 1




                                                                                                                      +1 for the new language. Another one to learn </sigh>
                                                                                                                      – ElPedro
                                                                                                                      18 hours ago














                                                                                                                    • 1




                                                                                                                      Is that a new golfing language I smell? :)
                                                                                                                      – ETHproductions
                                                                                                                      18 hours ago






                                                                                                                    • 1




                                                                                                                      +1 for the new language. Another one to learn </sigh>
                                                                                                                      – ElPedro
                                                                                                                      18 hours ago








                                                                                                                    1




                                                                                                                    1




                                                                                                                    Is that a new golfing language I smell? :)
                                                                                                                    – ETHproductions
                                                                                                                    18 hours ago




                                                                                                                    Is that a new golfing language I smell? :)
                                                                                                                    – ETHproductions
                                                                                                                    18 hours ago




                                                                                                                    1




                                                                                                                    1




                                                                                                                    +1 for the new language. Another one to learn </sigh>
                                                                                                                    – ElPedro
                                                                                                                    18 hours ago




                                                                                                                    +1 for the new language. Another one to learn </sigh>
                                                                                                                    – ElPedro
                                                                                                                    18 hours ago










                                                                                                                    up vote
                                                                                                                    1
                                                                                                                    down vote













                                                                                                                    TI-Basic, 8 bytes



                                                                                                                    4^5-.5sum(Ans





                                                                                                                    share|improve this answer

























                                                                                                                      up vote
                                                                                                                      1
                                                                                                                      down vote













                                                                                                                      TI-Basic, 8 bytes



                                                                                                                      4^5-.5sum(Ans





                                                                                                                      share|improve this answer























                                                                                                                        up vote
                                                                                                                        1
                                                                                                                        down vote










                                                                                                                        up vote
                                                                                                                        1
                                                                                                                        down vote









                                                                                                                        TI-Basic, 8 bytes



                                                                                                                        4^5-.5sum(Ans





                                                                                                                        share|improve this answer












                                                                                                                        TI-Basic, 8 bytes



                                                                                                                        4^5-.5sum(Ans






                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered 23 hours ago









                                                                                                                        Timtech

                                                                                                                        11.4k13659




                                                                                                                        11.4k13659






















                                                                                                                            up vote
                                                                                                                            1
                                                                                                                            down vote













                                                                                                                            Japt, 7 6 bytes



                                                                                                                            xz nH²


                                                                                                                            Try it or verify all test cases



                                                                                                                             z         :(Floor) divide each by 2
                                                                                                                            x :Reduce by addition
                                                                                                                            n :Subtract from
                                                                                                                            H : 32
                                                                                                                            ² : Squared





                                                                                                                            share|improve this answer



























                                                                                                                              up vote
                                                                                                                              1
                                                                                                                              down vote













                                                                                                                              Japt, 7 6 bytes



                                                                                                                              xz nH²


                                                                                                                              Try it or verify all test cases



                                                                                                                               z         :(Floor) divide each by 2
                                                                                                                              x :Reduce by addition
                                                                                                                              n :Subtract from
                                                                                                                              H : 32
                                                                                                                              ² : Squared





                                                                                                                              share|improve this answer

























                                                                                                                                up vote
                                                                                                                                1
                                                                                                                                down vote










                                                                                                                                up vote
                                                                                                                                1
                                                                                                                                down vote









                                                                                                                                Japt, 7 6 bytes



                                                                                                                                xz nH²


                                                                                                                                Try it or verify all test cases



                                                                                                                                 z         :(Floor) divide each by 2
                                                                                                                                x :Reduce by addition
                                                                                                                                n :Subtract from
                                                                                                                                H : 32
                                                                                                                                ² : Squared





                                                                                                                                share|improve this answer














                                                                                                                                Japt, 7 6 bytes



                                                                                                                                xz nH²


                                                                                                                                Try it or verify all test cases



                                                                                                                                 z         :(Floor) divide each by 2
                                                                                                                                x :Reduce by addition
                                                                                                                                n :Subtract from
                                                                                                                                H : 32
                                                                                                                                ² : Squared






                                                                                                                                share|improve this answer














                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer








                                                                                                                                edited 22 hours ago

























                                                                                                                                answered yesterday









                                                                                                                                Shaggy

                                                                                                                                17.9k21663




                                                                                                                                17.9k21663






















                                                                                                                                    up vote
                                                                                                                                    0
                                                                                                                                    down vote














                                                                                                                                    JavaScript (Node.js), 33 bytes





                                                                                                                                    a=>!a.map(n=>x-=n/2,x=1024)>x?0:x


                                                                                                                                    Try it online!



                                                                                                                                    Why you don't do on [1024,1024,1024]?






                                                                                                                                    share|improve this answer

























                                                                                                                                      up vote
                                                                                                                                      0
                                                                                                                                      down vote














                                                                                                                                      JavaScript (Node.js), 33 bytes





                                                                                                                                      a=>!a.map(n=>x-=n/2,x=1024)>x?0:x


                                                                                                                                      Try it online!



                                                                                                                                      Why you don't do on [1024,1024,1024]?






                                                                                                                                      share|improve this answer























                                                                                                                                        up vote
                                                                                                                                        0
                                                                                                                                        down vote










                                                                                                                                        up vote
                                                                                                                                        0
                                                                                                                                        down vote










                                                                                                                                        JavaScript (Node.js), 33 bytes





                                                                                                                                        a=>!a.map(n=>x-=n/2,x=1024)>x?0:x


                                                                                                                                        Try it online!



                                                                                                                                        Why you don't do on [1024,1024,1024]?






                                                                                                                                        share|improve this answer













                                                                                                                                        JavaScript (Node.js), 33 bytes





                                                                                                                                        a=>!a.map(n=>x-=n/2,x=1024)>x?0:x


                                                                                                                                        Try it online!



                                                                                                                                        Why you don't do on [1024,1024,1024]?







                                                                                                                                        share|improve this answer












                                                                                                                                        share|improve this answer



                                                                                                                                        share|improve this answer










                                                                                                                                        answered yesterday









                                                                                                                                        l4m2

                                                                                                                                        4,2341432




                                                                                                                                        4,2341432






















                                                                                                                                            up vote
                                                                                                                                            0
                                                                                                                                            down vote














                                                                                                                                            R, 17 bytes





                                                                                                                                            4^5-sum(scan())/2


                                                                                                                                            Try it online!






                                                                                                                                            share|improve this answer

























                                                                                                                                              up vote
                                                                                                                                              0
                                                                                                                                              down vote














                                                                                                                                              R, 17 bytes





                                                                                                                                              4^5-sum(scan())/2


                                                                                                                                              Try it online!






                                                                                                                                              share|improve this answer























                                                                                                                                                up vote
                                                                                                                                                0
                                                                                                                                                down vote










                                                                                                                                                up vote
                                                                                                                                                0
                                                                                                                                                down vote










                                                                                                                                                R, 17 bytes





                                                                                                                                                4^5-sum(scan())/2


                                                                                                                                                Try it online!






                                                                                                                                                share|improve this answer













                                                                                                                                                R, 17 bytes





                                                                                                                                                4^5-sum(scan())/2


                                                                                                                                                Try it online!







                                                                                                                                                share|improve this answer












                                                                                                                                                share|improve this answer



                                                                                                                                                share|improve this answer










                                                                                                                                                answered yesterday









                                                                                                                                                ngm

                                                                                                                                                2,92923




                                                                                                                                                2,92923






















                                                                                                                                                    up vote
                                                                                                                                                    0
                                                                                                                                                    down vote














                                                                                                                                                    TeaScript, 11 bytes





                                                                                                                                                    4p5)-(xx)/2


                                                                                                                                                    Try it online!






                                                                                                                                                    share|improve this answer

























                                                                                                                                                      up vote
                                                                                                                                                      0
                                                                                                                                                      down vote














                                                                                                                                                      TeaScript, 11 bytes





                                                                                                                                                      4p5)-(xx)/2


                                                                                                                                                      Try it online!






                                                                                                                                                      share|improve this answer























                                                                                                                                                        up vote
                                                                                                                                                        0
                                                                                                                                                        down vote










                                                                                                                                                        up vote
                                                                                                                                                        0
                                                                                                                                                        down vote










                                                                                                                                                        TeaScript, 11 bytes





                                                                                                                                                        4p5)-(xx)/2


                                                                                                                                                        Try it online!






                                                                                                                                                        share|improve this answer













                                                                                                                                                        TeaScript, 11 bytes





                                                                                                                                                        4p5)-(xx)/2


                                                                                                                                                        Try it online!







                                                                                                                                                        share|improve this answer












                                                                                                                                                        share|improve this answer



                                                                                                                                                        share|improve this answer










                                                                                                                                                        answered 22 hours ago









                                                                                                                                                        Luis felipe De jesus Munoz

                                                                                                                                                        3,70211051




                                                                                                                                                        3,70211051






















                                                                                                                                                            up vote
                                                                                                                                                            0
                                                                                                                                                            down vote














                                                                                                                                                            Stax, 6 bytes



                                                                                                                                                            ë3i─♠÷


                                                                                                                                                            Run and debug it






                                                                                                                                                            share|improve this answer

























                                                                                                                                                              up vote
                                                                                                                                                              0
                                                                                                                                                              down vote














                                                                                                                                                              Stax, 6 bytes



                                                                                                                                                              ë3i─♠÷


                                                                                                                                                              Run and debug it






                                                                                                                                                              share|improve this answer























                                                                                                                                                                up vote
                                                                                                                                                                0
                                                                                                                                                                down vote










                                                                                                                                                                up vote
                                                                                                                                                                0
                                                                                                                                                                down vote










                                                                                                                                                                Stax, 6 bytes



                                                                                                                                                                ë3i─♠÷


                                                                                                                                                                Run and debug it






                                                                                                                                                                share|improve this answer













                                                                                                                                                                Stax, 6 bytes



                                                                                                                                                                ë3i─♠÷


                                                                                                                                                                Run and debug it







                                                                                                                                                                share|improve this answer












                                                                                                                                                                share|improve this answer



                                                                                                                                                                share|improve this answer










                                                                                                                                                                answered 21 hours ago









                                                                                                                                                                recursive

                                                                                                                                                                4,8491221




                                                                                                                                                                4,8491221






















                                                                                                                                                                    up vote
                                                                                                                                                                    0
                                                                                                                                                                    down vote













                                                                                                                                                                    perl -aE, 27 bytes



                                                                                                                                                                    $"=$:;say eval"(2048-@F)/2"


                                                                                                                                                                    This reads a line with numbers (whitespace separated) from STDIN, and writes the answer to STDOUT.



                                                                                                                                                                    What it does is subtract all the numbers from the input from 2048, and it divides the remainder by 2. The -a switch puts the in the array @F (one number per element). If we interpolate an array into a string (which is what we are doing here), perl puts the value of $" between the elements. The little used variable $: is be default n-; and since white space between tokens is ignored, the result is subtracting all the numbers from 2048. The eval does the calculation.






                                                                                                                                                                    share|improve this answer

























                                                                                                                                                                      up vote
                                                                                                                                                                      0
                                                                                                                                                                      down vote













                                                                                                                                                                      perl -aE, 27 bytes



                                                                                                                                                                      $"=$:;say eval"(2048-@F)/2"


                                                                                                                                                                      This reads a line with numbers (whitespace separated) from STDIN, and writes the answer to STDOUT.



                                                                                                                                                                      What it does is subtract all the numbers from the input from 2048, and it divides the remainder by 2. The -a switch puts the in the array @F (one number per element). If we interpolate an array into a string (which is what we are doing here), perl puts the value of $" between the elements. The little used variable $: is be default n-; and since white space between tokens is ignored, the result is subtracting all the numbers from 2048. The eval does the calculation.






                                                                                                                                                                      share|improve this answer























                                                                                                                                                                        up vote
                                                                                                                                                                        0
                                                                                                                                                                        down vote










                                                                                                                                                                        up vote
                                                                                                                                                                        0
                                                                                                                                                                        down vote









                                                                                                                                                                        perl -aE, 27 bytes



                                                                                                                                                                        $"=$:;say eval"(2048-@F)/2"


                                                                                                                                                                        This reads a line with numbers (whitespace separated) from STDIN, and writes the answer to STDOUT.



                                                                                                                                                                        What it does is subtract all the numbers from the input from 2048, and it divides the remainder by 2. The -a switch puts the in the array @F (one number per element). If we interpolate an array into a string (which is what we are doing here), perl puts the value of $" between the elements. The little used variable $: is be default n-; and since white space between tokens is ignored, the result is subtracting all the numbers from 2048. The eval does the calculation.






                                                                                                                                                                        share|improve this answer












                                                                                                                                                                        perl -aE, 27 bytes



                                                                                                                                                                        $"=$:;say eval"(2048-@F)/2"


                                                                                                                                                                        This reads a line with numbers (whitespace separated) from STDIN, and writes the answer to STDOUT.



                                                                                                                                                                        What it does is subtract all the numbers from the input from 2048, and it divides the remainder by 2. The -a switch puts the in the array @F (one number per element). If we interpolate an array into a string (which is what we are doing here), perl puts the value of $" between the elements. The little used variable $: is be default n-; and since white space between tokens is ignored, the result is subtracting all the numbers from 2048. The eval does the calculation.







                                                                                                                                                                        share|improve this answer












                                                                                                                                                                        share|improve this answer



                                                                                                                                                                        share|improve this answer










                                                                                                                                                                        answered 19 hours ago









                                                                                                                                                                        Abigail

                                                                                                                                                                        41717




                                                                                                                                                                        41717






















                                                                                                                                                                            up vote
                                                                                                                                                                            0
                                                                                                                                                                            down vote














                                                                                                                                                                            Perl 6, 12 bytes





                                                                                                                                                                            1024-*.sum/2


                                                                                                                                                                            Try it online!



                                                                                                                                                                            Anonymous Whatever lambda that takes a list and returns a number.






                                                                                                                                                                            share|improve this answer

























                                                                                                                                                                              up vote
                                                                                                                                                                              0
                                                                                                                                                                              down vote














                                                                                                                                                                              Perl 6, 12 bytes





                                                                                                                                                                              1024-*.sum/2


                                                                                                                                                                              Try it online!



                                                                                                                                                                              Anonymous Whatever lambda that takes a list and returns a number.






                                                                                                                                                                              share|improve this answer























                                                                                                                                                                                up vote
                                                                                                                                                                                0
                                                                                                                                                                                down vote










                                                                                                                                                                                up vote
                                                                                                                                                                                0
                                                                                                                                                                                down vote










                                                                                                                                                                                Perl 6, 12 bytes





                                                                                                                                                                                1024-*.sum/2


                                                                                                                                                                                Try it online!



                                                                                                                                                                                Anonymous Whatever lambda that takes a list and returns a number.






                                                                                                                                                                                share|improve this answer













                                                                                                                                                                                Perl 6, 12 bytes





                                                                                                                                                                                1024-*.sum/2


                                                                                                                                                                                Try it online!



                                                                                                                                                                                Anonymous Whatever lambda that takes a list and returns a number.







                                                                                                                                                                                share|improve this answer












                                                                                                                                                                                share|improve this answer



                                                                                                                                                                                share|improve this answer










                                                                                                                                                                                answered 17 hours ago









                                                                                                                                                                                Jo King

                                                                                                                                                                                18.9k242101




                                                                                                                                                                                18.9k242101






















                                                                                                                                                                                    up vote
                                                                                                                                                                                    0
                                                                                                                                                                                    down vote













                                                                                                                                                                                    AWK, 26 bytes



                                                                                                                                                                                    {s+=$1}END{print 1024-s/2}


                                                                                                                                                                                    Input numbers are separated by newlines (i.e. one per line)






                                                                                                                                                                                    share|improve this answer

























                                                                                                                                                                                      up vote
                                                                                                                                                                                      0
                                                                                                                                                                                      down vote













                                                                                                                                                                                      AWK, 26 bytes



                                                                                                                                                                                      {s+=$1}END{print 1024-s/2}


                                                                                                                                                                                      Input numbers are separated by newlines (i.e. one per line)






                                                                                                                                                                                      share|improve this answer























                                                                                                                                                                                        up vote
                                                                                                                                                                                        0
                                                                                                                                                                                        down vote










                                                                                                                                                                                        up vote
                                                                                                                                                                                        0
                                                                                                                                                                                        down vote









                                                                                                                                                                                        AWK, 26 bytes



                                                                                                                                                                                        {s+=$1}END{print 1024-s/2}


                                                                                                                                                                                        Input numbers are separated by newlines (i.e. one per line)






                                                                                                                                                                                        share|improve this answer












                                                                                                                                                                                        AWK, 26 bytes



                                                                                                                                                                                        {s+=$1}END{print 1024-s/2}


                                                                                                                                                                                        Input numbers are separated by newlines (i.e. one per line)







                                                                                                                                                                                        share|improve this answer












                                                                                                                                                                                        share|improve this answer



                                                                                                                                                                                        share|improve this answer










                                                                                                                                                                                        answered 3 hours ago









                                                                                                                                                                                        iBug

                                                                                                                                                                                        1,187729




                                                                                                                                                                                        1,187729






















                                                                                                                                                                                            up vote
                                                                                                                                                                                            0
                                                                                                                                                                                            down vote













                                                                                                                                                                                            Neim, 6 bytes



                                                                                                                                                                                            Pretty new to Neim but got it working



                                                                                                                                                                                            𝐬ᚺςᚫᛦ𝕤


                                                                                                                                                                                            Explanation:



                                                                                                                                                                                              𝐬         : Sum input
                                                                                                                                                                                            ᚺ : Divide by 2 (stack now [input summed and divided by 2])
                                                                                                                                                                                            ς : Variable set to 16 pushed to stack
                                                                                                                                                                                            ᚫ : Multiply by 2
                                                                                                                                                                                            ᛦ : Square (stack now [input summed and divided by 2, 1024])
                                                                                                                                                                                            𝕤 : Subtract then absolute


                                                                                                                                                                                            Try it online!






                                                                                                                                                                                            share|improve this answer

























                                                                                                                                                                                              up vote
                                                                                                                                                                                              0
                                                                                                                                                                                              down vote













                                                                                                                                                                                              Neim, 6 bytes



                                                                                                                                                                                              Pretty new to Neim but got it working



                                                                                                                                                                                              𝐬ᚺςᚫᛦ𝕤


                                                                                                                                                                                              Explanation:



                                                                                                                                                                                                𝐬         : Sum input
                                                                                                                                                                                              ᚺ : Divide by 2 (stack now [input summed and divided by 2])
                                                                                                                                                                                              ς : Variable set to 16 pushed to stack
                                                                                                                                                                                              ᚫ : Multiply by 2
                                                                                                                                                                                              ᛦ : Square (stack now [input summed and divided by 2, 1024])
                                                                                                                                                                                              𝕤 : Subtract then absolute


                                                                                                                                                                                              Try it online!






                                                                                                                                                                                              share|improve this answer























                                                                                                                                                                                                up vote
                                                                                                                                                                                                0
                                                                                                                                                                                                down vote










                                                                                                                                                                                                up vote
                                                                                                                                                                                                0
                                                                                                                                                                                                down vote









                                                                                                                                                                                                Neim, 6 bytes



                                                                                                                                                                                                Pretty new to Neim but got it working



                                                                                                                                                                                                𝐬ᚺςᚫᛦ𝕤


                                                                                                                                                                                                Explanation:



                                                                                                                                                                                                  𝐬         : Sum input
                                                                                                                                                                                                ᚺ : Divide by 2 (stack now [input summed and divided by 2])
                                                                                                                                                                                                ς : Variable set to 16 pushed to stack
                                                                                                                                                                                                ᚫ : Multiply by 2
                                                                                                                                                                                                ᛦ : Square (stack now [input summed and divided by 2, 1024])
                                                                                                                                                                                                𝕤 : Subtract then absolute


                                                                                                                                                                                                Try it online!






                                                                                                                                                                                                share|improve this answer












                                                                                                                                                                                                Neim, 6 bytes



                                                                                                                                                                                                Pretty new to Neim but got it working



                                                                                                                                                                                                𝐬ᚺςᚫᛦ𝕤


                                                                                                                                                                                                Explanation:



                                                                                                                                                                                                  𝐬         : Sum input
                                                                                                                                                                                                ᚺ : Divide by 2 (stack now [input summed and divided by 2])
                                                                                                                                                                                                ς : Variable set to 16 pushed to stack
                                                                                                                                                                                                ᚫ : Multiply by 2
                                                                                                                                                                                                ᛦ : Square (stack now [input summed and divided by 2, 1024])
                                                                                                                                                                                                𝕤 : Subtract then absolute


                                                                                                                                                                                                Try it online!







                                                                                                                                                                                                share|improve this answer












                                                                                                                                                                                                share|improve this answer



                                                                                                                                                                                                share|improve this answer










                                                                                                                                                                                                answered 1 hour ago









                                                                                                                                                                                                LiefdeWen

                                                                                                                                                                                                2,492936




                                                                                                                                                                                                2,492936






















                                                                                                                                                                                                    up vote
                                                                                                                                                                                                    0
                                                                                                                                                                                                    down vote













                                                                                                                                                                                                    JAVA, 30 bytes



                                                                                                                                                                                                    2048-IntStream.of(a).sum()/2;





                                                                                                                                                                                                    share|improve this answer








                                                                                                                                                                                                    New contributor




                                                                                                                                                                                                    isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                    Check out our Code of Conduct.






















                                                                                                                                                                                                      up vote
                                                                                                                                                                                                      0
                                                                                                                                                                                                      down vote













                                                                                                                                                                                                      JAVA, 30 bytes



                                                                                                                                                                                                      2048-IntStream.of(a).sum()/2;





                                                                                                                                                                                                      share|improve this answer








                                                                                                                                                                                                      New contributor




                                                                                                                                                                                                      isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                      Check out our Code of Conduct.




















                                                                                                                                                                                                        up vote
                                                                                                                                                                                                        0
                                                                                                                                                                                                        down vote










                                                                                                                                                                                                        up vote
                                                                                                                                                                                                        0
                                                                                                                                                                                                        down vote









                                                                                                                                                                                                        JAVA, 30 bytes



                                                                                                                                                                                                        2048-IntStream.of(a).sum()/2;





                                                                                                                                                                                                        share|improve this answer








                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                        isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                        Check out our Code of Conduct.









                                                                                                                                                                                                        JAVA, 30 bytes



                                                                                                                                                                                                        2048-IntStream.of(a).sum()/2;






                                                                                                                                                                                                        share|improve this answer








                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                        isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                        Check out our Code of Conduct.









                                                                                                                                                                                                        share|improve this answer



                                                                                                                                                                                                        share|improve this answer






                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                        isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                        Check out our Code of Conduct.









                                                                                                                                                                                                        answered 32 mins ago









                                                                                                                                                                                                        isaace

                                                                                                                                                                                                        1113




                                                                                                                                                                                                        1113




                                                                                                                                                                                                        New contributor




                                                                                                                                                                                                        isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                        Check out our Code of Conduct.





                                                                                                                                                                                                        New contributor





                                                                                                                                                                                                        isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                        Check out our Code of Conduct.






                                                                                                                                                                                                        isaace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                                                                                                        Check out our Code of Conduct.






















                                                                                                                                                                                                            up vote
                                                                                                                                                                                                            0
                                                                                                                                                                                                            down vote














                                                                                                                                                                                                            RAD, 10 bytes



                                                                                                                                                                                                            1024-+/ω÷2


                                                                                                                                                                                                            Try it online!






                                                                                                                                                                                                            share|improve this answer

























                                                                                                                                                                                                              up vote
                                                                                                                                                                                                              0
                                                                                                                                                                                                              down vote














                                                                                                                                                                                                              RAD, 10 bytes



                                                                                                                                                                                                              1024-+/ω÷2


                                                                                                                                                                                                              Try it online!






                                                                                                                                                                                                              share|improve this answer























                                                                                                                                                                                                                up vote
                                                                                                                                                                                                                0
                                                                                                                                                                                                                down vote










                                                                                                                                                                                                                up vote
                                                                                                                                                                                                                0
                                                                                                                                                                                                                down vote










                                                                                                                                                                                                                RAD, 10 bytes



                                                                                                                                                                                                                1024-+/ω÷2


                                                                                                                                                                                                                Try it online!






                                                                                                                                                                                                                share|improve this answer













                                                                                                                                                                                                                RAD, 10 bytes



                                                                                                                                                                                                                1024-+/ω÷2


                                                                                                                                                                                                                Try it online!







                                                                                                                                                                                                                share|improve this answer












                                                                                                                                                                                                                share|improve this answer



                                                                                                                                                                                                                share|improve this answer










                                                                                                                                                                                                                answered 22 mins ago









                                                                                                                                                                                                                Zacharý

                                                                                                                                                                                                                5,07511035




                                                                                                                                                                                                                5,07511035






















                                                                                                                                                                                                                    micnap is a new contributor. Be nice, and check out our Code of Conduct.










                                                                                                                                                                                                                     

                                                                                                                                                                                                                    draft saved


                                                                                                                                                                                                                    draft discarded


















                                                                                                                                                                                                                    micnap is a new contributor. Be nice, and check out our Code of Conduct.













                                                                                                                                                                                                                    micnap is a new contributor. Be nice, and check out our Code of Conduct.












                                                                                                                                                                                                                    micnap is a new contributor. Be nice, and check out our Code of Conduct.















                                                                                                                                                                                                                     


                                                                                                                                                                                                                    draft saved


                                                                                                                                                                                                                    draft discarded














                                                                                                                                                                                                                    StackExchange.ready(
                                                                                                                                                                                                                    function () {
                                                                                                                                                                                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175765%2fcouch-2048-how-much-more-till-2048%23new-answer', 'question_page');
                                                                                                                                                                                                                    }
                                                                                                                                                                                                                    );

                                                                                                                                                                                                                    Post as a guest




















































































                                                                                                                                                                                                                    Popular posts from this blog

                                                                                                                                                                                                                    mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                                                                                                                                                                                                                    How to change which sound is reproduced for terminal bell?

                                                                                                                                                                                                                    Can I use Tabulator js library in my java Spring + Thymeleaf project?