Beta

Details of an N-Dimensional Hyperrectangle

Description
Loading description...
Geometry
Puzzles
  • Please sign in or sign up to leave a comment.
  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • saudiGuy Avatar

    Python: Random tests are vulnerable to input modification

  • readerboy7 Avatar

    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).

    • Joe Reece Avatar

      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.

      Issue marked resolved by Joe Reece 3 years ago
    • FArekkusu Avatar

      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.

    • CannockA133 Avatar

      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.

  • scarecrw Avatar

    Initial solution has the return statement flipped (swapped area & perimeter).

    Cool kata!

  • JohanWiltink Avatar

    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! )

  • Blind4Basics Avatar

    Hi,

    • the output type should be a tuple
    • the user could modify the input in the random tests and so bias the tests
    • in python there are tools t generate rnadom integers, you should use them ;)
    • don't compute several times the expected result (compute it before te assertion, that will handle the previous point as well)
    • would be good to have some more random tests... (50-100)
    • the suggestion below is actually an issue too (names conventions)

    cheers

  • Fbasham Avatar

    FYI, python uses snake_case as a naming convention instead of camelCase. Just a minor improvement you could make.

  • dolamroth Avatar

    The output type should be Tuple[int, int]

  • dolamroth Avatar

    Several bugs in sample tests and random tests.

    I.e., inconsistency between result of hyperRectangleDetails([]) in main test cases and sample tests.