Ad
  • Custom User Avatar

    That's an implementation detail I was relying on. Since that string's reference counter is 1, the add-assign operator could try to add to the existing string (while the add operator cannot do that, as the assignment comes later).

    Well, it used to be more efficient.

    I just did a timeit.timeit on Python 3.8.5 (on very long strings, a billion characters), and the add first then assign version was same for short strings, about twice as fast for longer strings. Which is the opposite of what I expected.

    Maybe I did my previous tests on Python 2.7, quite possible. Interesting, I never thought that part would change. Or my tests back then were wrong (I was still relatively new to Python).

    (My own solution does use a generator expression instead of a list, but pretty much agree on the overall design)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Not sure what you mean, if 111 represents a dot rather than dash, how do you explain the seven zeroes?

  • Custom User Avatar

    Insufficient tests, obviously, this code should not pass. Fails on d01(0, 0) and on d01(1, 3), for example.

  • Custom User Avatar

    Please add the word "regular" to the polygon. Imagine a non-regular polygon, for example a rectangle of 6x8 in a circle of radius 5. It has area 48, but you expect value 50 from a square.

  • Custom User Avatar

    That's because it's not square root, but cubic root of 1*2*6 (as those are three numbers).

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    The test cases are lacking a test for the first line [[2,5], [3,6]] is NOT the same as [[2,3], [5,6]]. Some solutions flatten the array for convenience and would not pass this test, yet they do while violating the very first of the numbered rules.

    Another thing that is not tested are duplicates. Different solutions have different opinions on whether same([[1,2],[1,2],[3,4]],[[1,2],[3,4],[3,4]]) should evaluate to true or not.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    That code does not like words consisting of Ts only (haven't seen them in the wild, yet they could be possible).

    '1110001110000000111' is clearly 'TT T', but the code converts it to morse code '..0.' and finally to ''

  • Custom User Avatar

    For the solution with every, [undefined].sameStructureAs([[1,[2]]]) returns true while [[1,[2]]].sameStructureAs([undefined]) returns false.

    Maybe this is a very exotic test case, but I like the idea of a.sameStructureAs(b)==b.sameStructureAs(a), which is violated here.