4 kyu

Play Tetris : Shape anastomosis

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

    For some reason few random tests are failing with expected '' for JavaScript, even though there is a clear solution it happens with 7-12 cases out of 100 only

  • elyasafe Avatar

    I was able to solve this kata while my algo was not complete.

    block:

         0    1    2
    0 [ '□', '□', '□' ]
    1 [ '■', '■', '□' ]
    

    board:

          0    1    2    3    4    5    6    7    8    9    10
    0  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    1  [ '■', '□', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    2  [ '■', '□', '□', '□', '■', '■', '■', '■', '■', '□', '■' ]
    3  [ '■', '■', '■', '■', '■', '■', '■', '□', '□', '□', '■' ]
    4  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    5  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    6  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    7  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    8  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    9  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    10 [ '■', '■', '■', '■', '■', '■', '□', '□', '□', '■', '■' ]
    11 [ '■', '■', '■', '□', '□', '□', '■', '■', '□', '■', '■' ]
    12 [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    

    To fix this issue, I suggest to add more constant test cases where each cell in the board that is adjacent to a block's empty cell outside the block is either '■' or '□' (only adjacent blocks that I consider as an "outer corner", i.e., not to the left/right/top/bottom of the block's empty cell.

    For example, if we take the board above, we need the following test cases where the above board is the same, except for the following cells:

    board[9][5]  = '■', board[9][5]  = '□'
    board[9][9]  = '■', board[9][9]  = '□'
    board[11][5] = '■', board[11][5] = '□'
    board[12][7] = '■', board[12][7] = '□'
    board[12][9] = '■', board[12][9] = '□'
    

    So, for the test case where board[9][5] = '□', the board will look like this:

          0    1    2    3    4    5    6    7    8    9    10
    0  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    1  [ '■', '□', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    2  [ '■', '□', '□', '□', '■', '■', '■', '■', '■', '□', '■' ]
    3  [ '■', '■', '■', '■', '■', '■', '■', '□', '□', '□', '■' ]
    4  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    5  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    6  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    7  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    8  [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    9  [ '■', '■', '■', '■', '■', '□', '■', '■', '■', '■', '■' ]
    10 [ '■', '■', '■', '■', '■', '■', '□', '□', '□', '■', '■' ]
    11 [ '■', '■', '■', '□', '□', '□', '■', '■', '□', '■', '■' ]
    12 [ '■', '■', '■', '■', '■', '■', '■', '■', '■', '■', '■' ]
    

    This will ensure that my method of solving this kata will not randomly pass the test cases.

  • elyasafe Avatar

    Guys, don't mutate the function inputs (board & block), otherwise the tests will fail! IMO, it should be mentioned in the description.

  • ejini战神 Avatar

    Great kata, brushed up on finding boundaires concept

  • hobovsky Avatar

    I think formatting in the description got messed up... A pity, because I would like to try the kata but now I have no idea what it is about ;)

  • user9959937 Avatar

    It appears that none of the random tests are working. They all required me to return "", even when there was an obvious solution.

  • user5036852 Avatar

    Great kata! I love Tetris!

  • gabbek Avatar

    Interesting kata, voted, ranked, approved.

  • goodwin64 Avatar

    This comment has been hidden.

  • goodwin64 Avatar

    Very nice, sapid and hard kata! Awesome!

    I was really inspired while solving :)

  • goodwin64 Avatar

    Please add some examples of input and output. I don't usually start Katas without it.

  • smile67 Avatar

    So... nice one again;-) Many thanks for the good katas!... But something is wrong with my solution or your random tests (probably my solution, which was very quick done, without optimizations;-))... First submit was ok, changed some useless things before final, second submit with no code changes throws one random error and third submit again ok... So no great thing, but a little "issue" i think;-)