# Project Euler #85: Counting rectangles

# Project Euler #85: Counting rectangles

kitchent + 0 comments Once again, a problem setting where an elegant approach becomes dirty because of large number of tests, compromise in memoization and memory management.

Hint: the count of a given rectangle is , where . Generate a list of (the upper bound can be found easily), and then a list of all results, sort them and find the nearest result(s). If it is not for the last 2 test cases, the overall performance would be much more impressive (a few ms vs a few sec).

Alexander125 + 1 comment It is strange, 6 tests are failed, but I got status "Accepted"

kk3799 + 0 comments Same thing happened with me ,i suggest you to handle the case where target is equidistant from two valid no. of rectangles possible .

toka_eldeeb + 0 comments can anyne help me with test cases so i can know where is the fault in my code

tanmaya_26 + 1 comment can we get testcases , atleast a few? some of my test cases are working but some are not. Out of a million possibilities it is hard to figure out the error in code ! help !!

shashank21jHackerRank AdminChallenge Author + 1 comment create a few testcase, write a brute force and check

acham_sanjeev + 0 comments can you share few more test cases, my code executed sucessfully for first test case rest are failed.

marckoch + 0 comments I have been stuck with this for a while. What saved me was thinking about the rectangle 1999 x 1 and how many rectangles it contains ;-)

opeispo + 1 comment I am not clear on the question . "Consider all the rectangular grids such that the number of rectangles contained in the grid is nearest to target . Out of all such rectangular grids output the area of the rectangular grid having the largest area" Care to give a concrete non-trivial example of what the set of rectangular grids nearest to target are.

andreshp + 1 comment - Target = 2
- Set of rectangular grids such as the number of rectangles contained is neares to the target = {(1,1), (1,2), (2,1)}
- The maximum area of the grids in the previus set = 2

Another one:

- Target = 33
- Set of rectangular grids such as the number of rectangles contained is neares to the target = {(1,8),(2,4),(3,3),(8,1),(4,2)} (which have 36 or 30 rectangles each)
- The maximum area of the grids in the previus set = 9

opeispo + 0 comments thanks

daidai + 1 comment Well I think I dont really understand the question, how will the grids format? will they always format like 2xn or not? for example, if there is 4 grid, will it be 2x2, or {2x2,1x4,4x1} or even {2x2,1x4,4x1, (3 up and 1 down), (1 up and 3 down)}? the question should clear such questions!

anuj_95 + 0 comments It has cleared such a question! Have you even read the explanation for Case 1 and Case 2 provided in the problem statement? A list of grids is given in the explanation where some of the grids in the list are not in the form of 2xn .

PeterSam77 + 0 comments The question is completly unclear.Any Ideas to understand it?

No more comments

Sort 9 Discussions, By:

Please Login in order to post a comment