Beta
Details of an N-Dimensional Hyperrectangle
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.
python new test framework is required. updated in this fork
Python: Random tests are vulnerable to input modification
new test framework should be implemented for sample tests also
Given that an n-dimenional cuboid of n=1 (i.e. a line) has its hyperperimeter being two points (which by definiton each have size of 1) , shouldn't the hyperperimeter be 2, not 0, in those cases?
i.e. it seems to me that
hyper_rectangle_details([n])
should equal (n, 2) not (n,0).Changed so that when n=0 → (None, None) is the solution, and when n=1 → (l, None) is the solution. I did this since my maths teachers couldn't decide what it would be and also due to the little amount of information of the topic on the web. If you can provide me with that says something otherwise as well as citing a credible source online then I promise you I will change it immediately.
The general case formula returns the same result as @readerboy7 suggests. If you don't know what the expected result should be, either ask for
None
, or don't use such inputs at all.(None, None)
for empty arrays and(n, None)
for 1-element-long arrays is a terrible choice.A 1d shape, a line, cannot have a hyperperimeter; there simply is no property of the line that could be called a hyperperimeter. The hyperperimeter is one dimension below the hyperarea of the shape, so a hyperperimeter of a line would be measured in meters (or insert other length unit) to the zeroth power - a dimensionless quantity which is always equal to one. A point is a zero-dimensional shape, so its volume is dimensionless, and its hyperperimeter would be measured in meters to the minus one, for example one per meter, even more nonsensical! There is no value you can assign to the hyperperimeter of a line or to the hyperperimeter or hyperarea of a point because these shapes inherently cannot have these properties, so the only sensible course of action is to return (length, None) or (None, None) in their place.
Initial solution has the return statement flipped (swapped area & perimeter).
Cool kata!
Thanks for letting me know
The possessive pronoun is "its", not "it's". Please get this right.
( If it sounds strange when you unpack it to "it is", it should be "its" and not "it's". )
( Also, my eyes! )
its fixed now!
errr, look at the solutions page: you broke everything, actually... ;)
somehow I doubt that's because of the description fixes .. :]
I was told to make it return a tuple not an array by you and @dolamroth, also I was told by you to generate more random test cases, as such all the solutions are now invalid. Do you think I should revert my changes, I'm kinda new to this.
oh sorry, my mistake. I totally forgot about my own request... ;s
Nope. This is what Beta is for. Existing solutions are fair game in Beta.
But while you are invalidating solutions, you might as well do all breaking changes at once. (for example changing
hyperRectangleDetails
tohyper_rectangle_details
)Hi,
cheers
for instance...
FYI, python uses snake_case as a naming convention instead of camelCase. Just a minor improvement you could make.
The output type should be
Tuple[int, int]
Several bugs in sample tests and random tests.
I.e., inconsistency between result of
hyperRectangleDetails([])
in main test cases and sample tests.What do you mean? Can you give a specific example?