4 kyu

Counting diamonds

86 of 94drchangliu
Description
Loading description...
Algorithms
Puzzles
  • Please sign in or sign up to leave a comment.
  • Awesome A.D. Avatar

    Python: The sorting requirement in the description and in the tests don't match.

    As described, the example output gets the second and third rectangles wrong (the second has a width of 2, the third a width of 1; the latter should come first as it shares a top left corner with the second but has a smaller width)

    [
      [(1, 1), (1, 2)], 
      [(2, 2), (2, 3)], 
      [(2, 2), (3, 2)] 
    ]
    

    The tests expect the output to simply be sorted lexicographically, i.e. without any special key function at all. This matches the output described above.

    The description should have this requirement removed for Python (don't know about Haskell tests).

  • RealKenshiro Avatar

    Very nice and creative Kata. Thanks!

  • RealKenshiro Avatar

    Very nice and creative Kata. Thanks!

  • natan Avatar

    Haskell translation

    • Tests and reference solution are 1:1 translations/copies from python. One difference is that the test generators generate 50 cases (they retry until success) instead of skipping cases with empty [] solutions... I think that's a bug in the python tests, not sure how it should be resolved.
    • I did not include a print function in preloaded. I all kinds of do not agree with preloaded, and printing doesn't make as much sense as it does in python since printing is an IO action and this is a pure function. Assertion failure messages do use that format though. (plus valid expressions that can be copied) I could put it back tbh (yeah I did implement it, and remove it) it's just that in my mind, it doesn't fit.
    • The reference solution has passed the python test suite 2000 times (called it with serialization + http) to be reasonably sure that it behaves the same.
    • The description is untouched
    • Type of a parcel is changed from [[(Int, Int)]] to ((Int, Int), (Int, Int)). this is not in any way imposed by the language, that just seems like the better fit. using (Int, Int, Int, Int) is the third option, and I slightly prefer that but opted for consistency with description/python there.

    Happy to change things, don't hold back. I might push back some but ultimately I am looking to match your intentions.

  • LostBit Avatar

    how many tests are there in total? Will help in terms of understanding how far off we are from completing before the timeout

  • Blind4Basics Avatar

    the sample tests aren't using the new test framework

  • user9644768 Avatar

    This is to avoid approval:

    1. Please increase the number of random tests otherwise it would be quite easy to slip through them:

    For example: This solution fails for the following(and several other inputs)

    [[1, 3, 5, 7, 6, 6, 4, 6, 10, 8], 
    [5, 1, 7, 8, 1, 1, 10, 1, 8, 4], 
    [10, 2, 0, 6, 3, 6, 9, 7, 10, 9], 
    [4, 9, 9, 2, 0, 4, 6, 4, 2, 4], 
    [9, 4, 1, 2, 4, 1, 4, 10, 5, 2], 
    [1, 9, 2, 6, 10, 10, 10, 4, 7, 3], 
    [5, 5, 6, 3, 2, 3, 8, 10, 6, 4], 
    [9, 2, 8, 9, 2, 8, 10, 10, 0, 10],
    [10, 0, 0, 2, 0, 5, 3, 3, 3, 0], 
    [3, 7, 2, 1, 10, 9, 3, 8, 5, 10]] 
    
    73
    
    1. Please make the timting consistent(I think increasing the number of random tests might make this better): For example: This solution, and as pointed out by mauro-1, h(is|er) solution takes (6 - 12+s).
  • mauro-1 Avatar

    In python coordinates should be tuples, not lists.

  • mauro-1 Avatar

    Excecution time is very variable -> random timeouts.

    Size of random tests should be more uniform between executions.

  • mauro-1 Avatar

    Order of parcels in result list is not specified.

  • mauro-1 Avatar

    map is a built-in function in python. It's better to use another name for the first parameter.

  • JohanWiltink Avatar

    Returning inconsistent datatypes is not a best practice. Consider asking for a list, possibly of length 0 or 1, of all possible solutions.

  • hobovsky Avatar

    Something is off with this sentence:

    Given a mininum number of diamonds, find out the smallest rectangle land parcel that contains that number of parcels.

    • If minimum amount of diamonds is asked, are parcels with larger amount also OK? Examples seem to show otherwise. If I want to get 3 diamonds, why is [[0,0], [0,0]] (a single area with 4 diamonds) not valid?
    • I believe the end of the sentence should read "[...] that contains that number of diamonds", does it?
  • JohanWiltink Avatar

    "parcel" is confusingly used for both land and diamonds.

    Given a mininum number of diamonds, find out the smallest rectangle land parcel that contains that number of parcels

    "exactly" that number seems to be missing here, and "minimum" is incorrect, because it implies any greater number is also acceptable and that seems not to be the case.

    The spacing of the map is incorrect in my webbrowser ( this may be my webbrowser's problem ).

  • user9644768 Avatar

    Thanks for a nice little kata.

    Here are few suggestion:

    1. Please change representation by 3️⃣ kind of characters because they're hard to read.(Background is whitish-blue and text is white)
    2. The theme is kinda competitive programming-ish, so please give constraints of values.
    3. For few couple of moments, I'd no idea how the rectangles were represented([upper_left_corner_coordinates, lower_right_corner_coordinates]), please add that in the description.