find the largest square foot given an area
Clash 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.
algorithms area recursion recursive-algorithms
add a comment |Â
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.
algorithms area recursion recursive-algorithms
1
$lfloorsqrt nrfloor$.
– MalayTheDynamo
Jul 29 at 8:07
add a comment |Â
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.
algorithms area recursion recursive-algorithms
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.
algorithms area recursion recursive-algorithms
edited Jul 29 at 6:13
asked Jul 29 at 5:44


Darren
133
133
1
$lfloorsqrt nrfloor$.
– MalayTheDynamo
Jul 29 at 8:07
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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)$
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
answered Aug 4 at 16:41


HugoTeixeira
15116
15116
add a comment |Â
add a comment |Â
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)$
add a comment |Â
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)$
add a comment |Â
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)$
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)$
answered Aug 4 at 16:58
James
643313
643313
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
$lfloorsqrt nrfloor$.
– MalayTheDynamo
Jul 29 at 8:07