Find the area of the smallest rectangle to contain squares of sizes up to nSquarefinder – Locating regular tetragonsFind the sequenceSylvester's sequenceMake your program sequential!Mondrian Puzzle SequenceDivinacci SequenceThe Lehmer-Comtet sequenceRectangular differenceYet Unused PairsPatience, young “Padovan”

Find the area of the smallest rectangle to contain squares of sizes up to n

Why are condenser mics so much more expensive than dynamics?

Why doesn't a particle exert force on itself?

What is a common way to tell if an academic is "above average," or outstanding in their field? Is their h-index (Hirsh index) one of them?

As a GM, is it bad form to ask for a moment to think when improvising?

How to replace space with '+' symbol in a triangular array?

How is trade in services conducted under the WTO in the absence of the Doha conclusion?

Is it normal for gliders not to have attitude indicators?

What does のそ mean on this picture?

Can I combine SELECT TOP() with the IN operator?

Huffman Code in C++

A 2-connected graph contains a path passing through all the odd degree vertices

All of my Firefox add-ons been disabled suddenly, how can I re-enable them?

Why does blending blueberries, milk, banana and vanilla extract cause the mixture to have a yogurty consistency?

Collision domain question

Primes in a Diamond

My large rocket is still flipping over

How did the Apollo guidance computer handle parity bit errors?

Two denim hijabs

When did England stop being a Papal fief?

How to use awk to extract data from a file based on the content of another file?

Endgame puzzle: How to avoid stalemate and win?

Is crescere the correct word meaning to to grow or cultivate?

Changing stroke width vertically but not horizontally in Inkscape



Find the area of the smallest rectangle to contain squares of sizes up to n


Squarefinder – Locating regular tetragonsFind the sequenceSylvester's sequenceMake your program sequential!Mondrian Puzzle SequenceDivinacci SequenceThe Lehmer-Comtet sequenceRectangular differenceYet Unused PairsPatience, young “Padovan”













4












$begingroup$


This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following:



  • Accept no or any input, and output A038666 until the heat death of the universe.

  • Accept a positive integer as input, and output the nth term of A038666 or its first n terms. (If using 0- instead of 1-indexing, then of course you also have to output 1 on 0 input.)

The nth term of A038666 is the least area among rectangles that contain nonoverlapping squares of sizes 1×1, 2×2,… n×n if you're using 1-indexing.



Example:



The smallest rectangle which can contain non-overlapping squares of $1times1$ to $4times4$ has a size of $7times5$:



4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 2 2 1
x x x x 2 2 x


Therefore, $a(4)=7times5=35$ (1-indexed).












share|improve this question











$endgroup$











  • $begingroup$
    For some reason my browser appears to be broken and I can't go to the linked website. Could you please post some examples of expected input and output? Thanks!
    $endgroup$
    – ElPedro
    6 hours ago










  • $begingroup$
    I've added an example. But feel free to either rollback or edit further.
    $endgroup$
    – Arnauld
    5 hours ago






  • 1




    $begingroup$
    A couple more test cases including an odd number and a large(r) number would be useful.
    $endgroup$
    – Shaggy
    5 hours ago















4












$begingroup$


This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following:



  • Accept no or any input, and output A038666 until the heat death of the universe.

  • Accept a positive integer as input, and output the nth term of A038666 or its first n terms. (If using 0- instead of 1-indexing, then of course you also have to output 1 on 0 input.)

The nth term of A038666 is the least area among rectangles that contain nonoverlapping squares of sizes 1×1, 2×2,… n×n if you're using 1-indexing.



Example:



The smallest rectangle which can contain non-overlapping squares of $1times1$ to $4times4$ has a size of $7times5$:



4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 2 2 1
x x x x 2 2 x


Therefore, $a(4)=7times5=35$ (1-indexed).












share|improve this question











$endgroup$











  • $begingroup$
    For some reason my browser appears to be broken and I can't go to the linked website. Could you please post some examples of expected input and output? Thanks!
    $endgroup$
    – ElPedro
    6 hours ago










  • $begingroup$
    I've added an example. But feel free to either rollback or edit further.
    $endgroup$
    – Arnauld
    5 hours ago






  • 1




    $begingroup$
    A couple more test cases including an odd number and a large(r) number would be useful.
    $endgroup$
    – Shaggy
    5 hours ago













4












4








4





$begingroup$


This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following:



  • Accept no or any input, and output A038666 until the heat death of the universe.

  • Accept a positive integer as input, and output the nth term of A038666 or its first n terms. (If using 0- instead of 1-indexing, then of course you also have to output 1 on 0 input.)

The nth term of A038666 is the least area among rectangles that contain nonoverlapping squares of sizes 1×1, 2×2,… n×n if you're using 1-indexing.



Example:



The smallest rectangle which can contain non-overlapping squares of $1times1$ to $4times4$ has a size of $7times5$:



4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 2 2 1
x x x x 2 2 x


Therefore, $a(4)=7times5=35$ (1-indexed).












share|improve this question











$endgroup$




This is a sequence question of the usual type, as applied to OEIS sequence A038666. That is, do either of the following:



  • Accept no or any input, and output A038666 until the heat death of the universe.

  • Accept a positive integer as input, and output the nth term of A038666 or its first n terms. (If using 0- instead of 1-indexing, then of course you also have to output 1 on 0 input.)

The nth term of A038666 is the least area among rectangles that contain nonoverlapping squares of sizes 1×1, 2×2,… n×n if you're using 1-indexing.



Example:



The smallest rectangle which can contain non-overlapping squares of $1times1$ to $4times4$ has a size of $7times5$:



4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 3 3 3
4 4 4 4 2 2 1
x x x x 2 2 x


Therefore, $a(4)=7times5=35$ (1-indexed).









code-golf packing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago









Arnauld

83k798340




83k798340










asked 6 hours ago









msh210msh210

2,3871231




2,3871231











  • $begingroup$
    For some reason my browser appears to be broken and I can't go to the linked website. Could you please post some examples of expected input and output? Thanks!
    $endgroup$
    – ElPedro
    6 hours ago










  • $begingroup$
    I've added an example. But feel free to either rollback or edit further.
    $endgroup$
    – Arnauld
    5 hours ago






  • 1




    $begingroup$
    A couple more test cases including an odd number and a large(r) number would be useful.
    $endgroup$
    – Shaggy
    5 hours ago
















  • $begingroup$
    For some reason my browser appears to be broken and I can't go to the linked website. Could you please post some examples of expected input and output? Thanks!
    $endgroup$
    – ElPedro
    6 hours ago










  • $begingroup$
    I've added an example. But feel free to either rollback or edit further.
    $endgroup$
    – Arnauld
    5 hours ago






  • 1




    $begingroup$
    A couple more test cases including an odd number and a large(r) number would be useful.
    $endgroup$
    – Shaggy
    5 hours ago















$begingroup$
For some reason my browser appears to be broken and I can't go to the linked website. Could you please post some examples of expected input and output? Thanks!
$endgroup$
– ElPedro
6 hours ago




$begingroup$
For some reason my browser appears to be broken and I can't go to the linked website. Could you please post some examples of expected input and output? Thanks!
$endgroup$
– ElPedro
6 hours ago












$begingroup$
I've added an example. But feel free to either rollback or edit further.
$endgroup$
– Arnauld
5 hours ago




$begingroup$
I've added an example. But feel free to either rollback or edit further.
$endgroup$
– Arnauld
5 hours ago




1




1




$begingroup$
A couple more test cases including an odd number and a large(r) number would be useful.
$endgroup$
– Shaggy
5 hours ago




$begingroup$
A couple more test cases including an odd number and a large(r) number would be useful.
$endgroup$
– Shaggy
5 hours ago










1 Answer
1






active

oldest

votes


















3












$begingroup$

JavaScript (ES6),  209  183 bytes



1-indexed.





f=(n,a,S=(n,c)=>n?c(--n)||S(n,c):0)=>S(a+1,w=>a%w?0:(F=(l,n)=>n?S(w,x=>S(h=a/w,y=>x+n>w|y+n>h|l.some(([X,Y,W])=>X<x+n&X+W>x&Y<y+n&Y+W>y)?0:F([...l,[x,y,n]],n-1))):1)([],n))?a:f(n,-~a)


Try it online!






share|improve this answer











$endgroup$













    Your Answer






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

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

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

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f185221%2ffind-the-area-of-the-smallest-rectangle-to-contain-squares-of-sizes-up-to-n%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3












    $begingroup$

    JavaScript (ES6),  209  183 bytes



    1-indexed.





    f=(n,a,S=(n,c)=>n?c(--n)||S(n,c):0)=>S(a+1,w=>a%w?0:(F=(l,n)=>n?S(w,x=>S(h=a/w,y=>x+n>w|y+n>h|l.some(([X,Y,W])=>X<x+n&X+W>x&Y<y+n&Y+W>y)?0:F([...l,[x,y,n]],n-1))):1)([],n))?a:f(n,-~a)


    Try it online!






    share|improve this answer











    $endgroup$

















      3












      $begingroup$

      JavaScript (ES6),  209  183 bytes



      1-indexed.





      f=(n,a,S=(n,c)=>n?c(--n)||S(n,c):0)=>S(a+1,w=>a%w?0:(F=(l,n)=>n?S(w,x=>S(h=a/w,y=>x+n>w|y+n>h|l.some(([X,Y,W])=>X<x+n&X+W>x&Y<y+n&Y+W>y)?0:F([...l,[x,y,n]],n-1))):1)([],n))?a:f(n,-~a)


      Try it online!






      share|improve this answer











      $endgroup$















        3












        3








        3





        $begingroup$

        JavaScript (ES6),  209  183 bytes



        1-indexed.





        f=(n,a,S=(n,c)=>n?c(--n)||S(n,c):0)=>S(a+1,w=>a%w?0:(F=(l,n)=>n?S(w,x=>S(h=a/w,y=>x+n>w|y+n>h|l.some(([X,Y,W])=>X<x+n&X+W>x&Y<y+n&Y+W>y)?0:F([...l,[x,y,n]],n-1))):1)([],n))?a:f(n,-~a)


        Try it online!






        share|improve this answer











        $endgroup$



        JavaScript (ES6),  209  183 bytes



        1-indexed.





        f=(n,a,S=(n,c)=>n?c(--n)||S(n,c):0)=>S(a+1,w=>a%w?0:(F=(l,n)=>n?S(w,x=>S(h=a/w,y=>x+n>w|y+n>h|l.some(([X,Y,W])=>X<x+n&X+W>x&Y<y+n&Y+W>y)?0:F([...l,[x,y,n]],n-1))):1)([],n))?a:f(n,-~a)


        Try it online!







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 hours ago

























        answered 2 hours ago









        ArnauldArnauld

        83k798340




        83k798340



























            draft saved

            draft discarded
















































            If this is an answer to a challenge…



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


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


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


            More generally…



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


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




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f185221%2ffind-the-area-of-the-smallest-rectangle-to-contain-squares-of-sizes-up-to-n%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Log på Navigationsmenu

            Wonderful Copenhagen (sang) Eksterne henvisninger | NavigationsmenurSide på frankloesser.comWonderful Copenhagen

            Detroit Tigers Spis treści Historia | Skład zespołu | Sukcesy | Członkowie Baseball Hall of Fame | Zastrzeżone numery | Przypisy | Menu nawigacyjneEncyclopedia of Detroit - Detroit TigersTigers Stadium, Detroit, MITigers Timeline 1900sDetroit Tigers Team History & EncyclopediaTigers Timeline 1910s1935 World Series1945 World Series1945 World Series1984 World SeriesComerica Park, Detroit, MI2006 World Series2012 World SeriesDetroit Tigers 40-Man RosterDetroit Tigers Coaching StaffTigers Hall of FamersTigers Retired Numberse