### Thread: Need help with an assignment!

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Posts
1
Rep Power
0

#### Need help with an assignment!

Ok, so the assignment is to find the biggest "free square" in a grid where some spots are filled, for example, there's this grid:

###---
###---
###---
---###
---###
---###

Where "-" is a filled spot and "#" is a free zone.
This is done by filling a nested list:
[[###---],[###---],...,[---###]]
The inner lists are the vertical lines on the grid.
So this grid could be filled in any way, and I'm supposed to find a way to 'calculate' the biggest possible square that can still be filled. In the above example, the output would be: 9.
I'll give another example to make things clear:

##########
##### ---- #
## --# ---- #
## --# ---- #
## --# ---- #
## --# ---- #
##### ---- #
##########
- #### ---- #
##########

The output here should be 16, wich is the square from (1,6) to (4,9) (counting from 0)

I hope someone could help me with this problem, thanks in advance!
2. No Profile Picture
Contributing User
Devshed Novice (500 - 999 posts)

Join Date
May 2009
Posts
653
Rep Power
39
Originally Posted by toxic345
##########
##### ---- #
## --# ---- #
## --# ---- #
## --# ---- #
## --# ---- #
##### ---- #
##########
- #### ---- #
##########

The output here should be 16, wich is the square from (1,6) to (4,9) (counting from 0)
There are spaces in the 2nd example so I'm not sure if the spaces are spaces or the hash is spaces. But anyway, go through the list one row at a time and find the location of the spaces in that row. Then check how many following rows also have spaces at the same location. Put the results in a list of lists and then check to see which one is largest, i.e. contains the greatest number of spaces. Post back with your code for further help.
The output here should be 16, wich is the square from (1,6) to (4,9) (counting from 0)
Those are filled, not empty spaces. The answer is indeed 16 for the 2nd example, and there are two that qualify. Misunderstanding the question and having no idea how to loop through a list says that you aren't paying attention to the problem or in class. Hopefully that is a helpful hint.
Last edited by dwblas; May 12th, 2013 at 02:43 PM.