7 kyu
Number of Rectangles in a Grid
1,163 of 4,461pj6444
Loading description...
Geometry
Puzzles
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Java:
Missing fixed tests
Reference solution should be
private
What's the aim of this kata? If you want coder to derive the equation, it's National Math Olympiad level problem and surely not 7th level. If you want coder to google the formula it's just a google question and not worth even 8th level.
Description should be language-agnostic
^^
nice math problem
One of the "harder 7kyu"s
Factor translation
Approved
COBOL translation updated to version "3.1 (IBM)" -> not backward-compatible.
Don't think this a great kata, mostly a math question. Really doesn't challenge anyone's programming skills in the slightest.
I am a simple man - I see a math kata, I Google the formula.
Ruby and python tests should be updated to current test framework
fixed, JS updated as well !
COBOL translation please review carefully
Knowing the Gauss equation allows you to solve tons of these kinds of problems
R translation (author inactive)
approved by
C Translation kumited.
approved
maths, not code!
there are many math problems when we are coding,some skills can raise up the program operation efficiency.
how this looks extremely tricky. However, if there's a mathematical shortcut....maybe it's solvable
What the heck does this have to do with learning to code? It's just a math problem.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
!
Not the kind of problem I'm interested in. "Oh, look, a math riddle. lmgtfy!" Apparently other people like it, though.
This comment has been hidden.
When I submit my code, I get the error:
File "", line 9 from random import randint ^ SyntaxError: invalid syntax
I'm not using that line in my code so i'm not sure what this error is referring? I'm guessing it has something to do with the test case which i have blank.
cheers
I keep getting this error and I don't know why even though my code passes the tests correctly
shouldWork(RectTest) / by zero
Not really sure how to fix this, I'm guessing it is suggesting I am dividing by 0 even though I am not
Hi pj,
kust translated it into Haskell (I hope it is good enough, but any feed from more advanced Haskell users is always welcome), if you want to approve it and a coffeescript translation which seems to be still pending.
Let me know if you are interested in random tests cases to other languages too and if you think what I replied to wthit down below here may be a good addition to the description :)
Just approved them and added addition to the description. Many thanks for that. The random test cases would be much appreciated.
Done, checked that even in JS we stay in the safe perimeter of its double float precision even with edge cases and many thanks to you again for providing me with this fancy brain-teaser :)
This comment has been hidden.
What about finding the number of squares? Any idea? The Kata was ambiguous to me (thought of squares instead of rectangles, spent time trying to figure out)....
Your efforts may have not be in vain, then: try this ;)
Hey, great kata. Luckily, I remembered the formula for this right away. I submitted a CoffeeScript translation, if you'd like to check that out.
Really simple, immediate yet fancy kata; I didn't know the trick to solve it, so I pondered about it on a 30 minutes or so walk by the beach and come up with the right solution: I really like when it goes that way :)
As I owe you one for this, I hope that I will be able to translate it into Haskell anytime soon, plus if you want random test cases addes to the JS, Python or Ruby versions, just ask :)
Oh, and of course this kata is now approved and thus visible to every code-warrior out there :)!
What do you mean by
total number of rectangles contained in this rectangle
? Are you talking about all possible sizes and positions, in integers?Yeah, that is the idea, as far as I can see.
And to make it a bit less ambigous for the next codewarriors trying this nice kata: you must also include overlapping rectangles in the count.
Ie: the 3*2 rectangle can be seen as as the basic ground for:
1 rectangle sized 3*2:
2 rectangles sized 3*1:
4 rectangles sized 2*1:
2 rectangles sized 2*2:
3 rectangles sized 1*2:
6 rectangles sized 1*1:
Grand total: 18 possible rectangles.
[Do you think adding this to the description may help?]
Hello, if we have 1 rectangle sized 32 and 6 rectangles sized 1x1 they are equal and total count of rectangles == 6. But 4 rectangles sized 21 == 8. Are you sure that 4 rectangles sized 2x1 is correct value? for n = 2 and m = 3 ?
Remember, rectangles can overlap each other. They don't need to all fit in at once.
For Python,
snake_case
is the standard for naming functions, notcamelCase
. I'm not sure, but this possibly also applies to Ruby. I suggest renaming the function for Python ASAP, while in early beta.Fixed. Thank you for the suggestions!
EDIT: I fixed it in the editor, but the change is not there for the python solution. Maybe it will just take a little while to update.