find the largest square foot given an area

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












Given an area of n square foot, I need to be able to find the largest square foot I could make in the given area.



Example: if I had a total area of 12 square foot, I would be able to make one 3x3 square (with a total area of 9), and that would leave 3 square foot.
12 = [9, 1, 1, 1]



How do I solve this? or If you could just point me in the right direction that would be cool too. I just don't know what to google honestly.



the Euclidean algorithm seems to be the answer but that requires two input, now I am thinking maybe I can get the area's square root?



Now, I little background about this problem. I just started learning python programming and I was practicing on a website called "https://www.codewars.com", so yeah I am stuck on this "Kata". yes, I can skip it but I actually want to know how to solve this. please help.







share|cite|improve this question

















  • 1




    $lfloorsqrt nrfloor$.
    – MalayTheDynamo
    Jul 29 at 8:07














up vote
1
down vote

favorite












Given an area of n square foot, I need to be able to find the largest square foot I could make in the given area.



Example: if I had a total area of 12 square foot, I would be able to make one 3x3 square (with a total area of 9), and that would leave 3 square foot.
12 = [9, 1, 1, 1]



How do I solve this? or If you could just point me in the right direction that would be cool too. I just don't know what to google honestly.



the Euclidean algorithm seems to be the answer but that requires two input, now I am thinking maybe I can get the area's square root?



Now, I little background about this problem. I just started learning python programming and I was practicing on a website called "https://www.codewars.com", so yeah I am stuck on this "Kata". yes, I can skip it but I actually want to know how to solve this. please help.







share|cite|improve this question

















  • 1




    $lfloorsqrt nrfloor$.
    – MalayTheDynamo
    Jul 29 at 8:07












up vote
1
down vote

favorite









up vote
1
down vote

favorite











Given an area of n square foot, I need to be able to find the largest square foot I could make in the given area.



Example: if I had a total area of 12 square foot, I would be able to make one 3x3 square (with a total area of 9), and that would leave 3 square foot.
12 = [9, 1, 1, 1]



How do I solve this? or If you could just point me in the right direction that would be cool too. I just don't know what to google honestly.



the Euclidean algorithm seems to be the answer but that requires two input, now I am thinking maybe I can get the area's square root?



Now, I little background about this problem. I just started learning python programming and I was practicing on a website called "https://www.codewars.com", so yeah I am stuck on this "Kata". yes, I can skip it but I actually want to know how to solve this. please help.







share|cite|improve this question













Given an area of n square foot, I need to be able to find the largest square foot I could make in the given area.



Example: if I had a total area of 12 square foot, I would be able to make one 3x3 square (with a total area of 9), and that would leave 3 square foot.
12 = [9, 1, 1, 1]



How do I solve this? or If you could just point me in the right direction that would be cool too. I just don't know what to google honestly.



the Euclidean algorithm seems to be the answer but that requires two input, now I am thinking maybe I can get the area's square root?



Now, I little background about this problem. I just started learning python programming and I was practicing on a website called "https://www.codewars.com", so yeah I am stuck on this "Kata". yes, I can skip it but I actually want to know how to solve this. please help.









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Jul 29 at 6:13
























asked Jul 29 at 5:44









Darren

133




133







  • 1




    $lfloorsqrt nrfloor$.
    – MalayTheDynamo
    Jul 29 at 8:07












  • 1




    $lfloorsqrt nrfloor$.
    – MalayTheDynamo
    Jul 29 at 8:07







1




1




$lfloorsqrt nrfloor$.
– MalayTheDynamo
Jul 29 at 8:07




$lfloorsqrt nrfloor$.
– MalayTheDynamo
Jul 29 at 8:07










2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










As commented by MalayTheDynamo, you should use the floor of the square root of the area. Here is a simple python program that explains how to code this:



import math

def find_largest_square(area):
max_side = math.floor(math.sqrt(area))
print "area:", area, "=>", max_side, "x", max_side

find_largest_square(12)
find_largest_square(17)


So the math is done in the first line of the find_largest_square function:



max_side = math.floor(math.sqrt(area))


When we run this program it prints:



area: 12 => 3.0 x 3.0
area: 17 => 4.0 x 4.0





share|cite|improve this answer




























    up vote
    0
    down vote













    Suppose given area is A



    now let's find the side of the square
    x*x=A



    thus $x=sqrt(A)$ because side is always positive



    but you are looking for an integer



    thus take the floor



    your answer is the floor of $(sqrt A)$






    share|cite|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.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "69"
      ;
      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: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      noCode: true, onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );








       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2865807%2ffind-the-largest-square-foot-given-an-area%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote



      accepted










      As commented by MalayTheDynamo, you should use the floor of the square root of the area. Here is a simple python program that explains how to code this:



      import math

      def find_largest_square(area):
      max_side = math.floor(math.sqrt(area))
      print "area:", area, "=>", max_side, "x", max_side

      find_largest_square(12)
      find_largest_square(17)


      So the math is done in the first line of the find_largest_square function:



      max_side = math.floor(math.sqrt(area))


      When we run this program it prints:



      area: 12 => 3.0 x 3.0
      area: 17 => 4.0 x 4.0





      share|cite|improve this answer

























        up vote
        0
        down vote



        accepted










        As commented by MalayTheDynamo, you should use the floor of the square root of the area. Here is a simple python program that explains how to code this:



        import math

        def find_largest_square(area):
        max_side = math.floor(math.sqrt(area))
        print "area:", area, "=>", max_side, "x", max_side

        find_largest_square(12)
        find_largest_square(17)


        So the math is done in the first line of the find_largest_square function:



        max_side = math.floor(math.sqrt(area))


        When we run this program it prints:



        area: 12 => 3.0 x 3.0
        area: 17 => 4.0 x 4.0





        share|cite|improve this answer























          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          As commented by MalayTheDynamo, you should use the floor of the square root of the area. Here is a simple python program that explains how to code this:



          import math

          def find_largest_square(area):
          max_side = math.floor(math.sqrt(area))
          print "area:", area, "=>", max_side, "x", max_side

          find_largest_square(12)
          find_largest_square(17)


          So the math is done in the first line of the find_largest_square function:



          max_side = math.floor(math.sqrt(area))


          When we run this program it prints:



          area: 12 => 3.0 x 3.0
          area: 17 => 4.0 x 4.0





          share|cite|improve this answer













          As commented by MalayTheDynamo, you should use the floor of the square root of the area. Here is a simple python program that explains how to code this:



          import math

          def find_largest_square(area):
          max_side = math.floor(math.sqrt(area))
          print "area:", area, "=>", max_side, "x", max_side

          find_largest_square(12)
          find_largest_square(17)


          So the math is done in the first line of the find_largest_square function:



          max_side = math.floor(math.sqrt(area))


          When we run this program it prints:



          area: 12 => 3.0 x 3.0
          area: 17 => 4.0 x 4.0






          share|cite|improve this answer













          share|cite|improve this answer



          share|cite|improve this answer











          answered Aug 4 at 16:41









          HugoTeixeira

          15116




          15116




















              up vote
              0
              down vote













              Suppose given area is A



              now let's find the side of the square
              x*x=A



              thus $x=sqrt(A)$ because side is always positive



              but you are looking for an integer



              thus take the floor



              your answer is the floor of $(sqrt A)$






              share|cite|improve this answer

























                up vote
                0
                down vote













                Suppose given area is A



                now let's find the side of the square
                x*x=A



                thus $x=sqrt(A)$ because side is always positive



                but you are looking for an integer



                thus take the floor



                your answer is the floor of $(sqrt A)$






                share|cite|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Suppose given area is A



                  now let's find the side of the square
                  x*x=A



                  thus $x=sqrt(A)$ because side is always positive



                  but you are looking for an integer



                  thus take the floor



                  your answer is the floor of $(sqrt A)$






                  share|cite|improve this answer













                  Suppose given area is A



                  now let's find the side of the square
                  x*x=A



                  thus $x=sqrt(A)$ because side is always positive



                  but you are looking for an integer



                  thus take the floor



                  your answer is the floor of $(sqrt A)$







                  share|cite|improve this answer













                  share|cite|improve this answer



                  share|cite|improve this answer











                  answered Aug 4 at 16:58









                  James

                  643313




                  643313






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2865807%2ffind-the-largest-square-foot-given-an-area%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What is the equation of a 3D cone with generalised tilt?

                      Color the edges and diagonals of a regular polygon

                      Relationship between determinant of matrix and determinant of adjoint?