5 kyu

Blobservation 2: Merge Inert Blobs

38 of 88docgunthrop
Description
Loading description...
Arrays
Algorithms
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar
    • It seems "concurrent movement" is illdefined:
      • Why does [ [4,0,0,6,0,8] ] -> 'E' result in [ [18] ] while [ [9,4,6] ] -> 'E' results in [ [0,9,10] ]?
      • It looks to me in the first example 6 merges into 8, before 4 merges into 14 (6 + 8), resulting in 18 ...
      • ... while in the second example 9 bounces against 4, making it ineligible for a merge, before 4 merges with 6 into 10
  • RealKenshiro Avatar

    Once again, a excellent Kata from @docgunthrop... Thanks!

  • Nam01ar Avatar

    javascript- This example. [0,9,10], [8,8,8], [0,0,18] "S" [0,9,10], [8,8,26]

    shouldnt result be [0,9,10], [8,8,0] [0,0,26] as "S" moves downwards. 8 merges with 18 downwards and stays there. why does it go 26 to the middle?

  • radionnazmiev Avatar

    This comment has been hidden.

  • Awesome A.D. Avatar

    Nice Kata! I figured I'd do this one before attempting Blobservation because that is rated as more difficult, however I was rather surprised at the complexity of this one (getting it to run in roughly O(N) time wasn't quite as trivial as I assumed). The 5 kyu rating for this kata surprised me, compared to other 5 kyu problems. Oh well, off to the next!

  • MarkyMark1000 Avatar

    I really like this Kata, however there is a small minor point that I found a little bit unclear. If you input a string like "NE", do the blobs move North one step and then east or do they move in a north easterly (diagonal) direction ? I suspect it moves North one step and then east, however it would be great if you could update the question to make it absolutely clear what happens.

  • user8436785 Avatar

    Needs updated to Rust 1.49.

  • belikcost Avatar

    I made this kata even though I recently thought it was impossible. Thanks!

  • Fbasham Avatar

    Awesome kata. Definitely worth doing.

  • user7820265 Avatar

    This comment has been hidden.

  • docgunthrop Avatar

    Reserved translations to come:

    • Python
    • Kotlin
    • Rust
    • C#
    • Go (?)
  • JohanWiltink Avatar

    Mention your anti-cheat !!

    I was having major problems with class Blobservation extends Array; could not figure out where that came from, and ultimately gave up on that idea.

    I can't even be sure the anti-cheat was the problem, because stuff fails silently with all the fiddling you're doing.

    Please, if you fiddle with JS internals, mention such in the description. You don't have to specify every little change, but a general warning means I'll have the idea to test in a pristine environment.

  • JohanWiltink Avatar

    Having the functionality in a class adds nothing. A class is useful when there is state, but there is no state. Having an input as the state adds nothing but boilerplate.

    You could just as easily ask for a function slide(grid,instructions) which returns a new grid.

    Actually, slide(grid,instruction) ( note single instruction ) would allow slide(grid,instructions) = instructions.reduce(slide,grid), so even handling multiple instructions doesn't add much of anything.

    I'd suggest asking for slide(grid,instruction).

  • Blind4Basics Avatar

    Hi doc,

    It seems there might be something wrong in your ref solution. That or some explanations are missing from the description, I believe:

    NEWE
    [
      [ 61,  0,   0,   0,   0,   0 ],
      [ 37, 57, 120, 181, 292, 361 ],
    ]
    expected [ [ 1109 ] ] to deeply equal [ [ 98, 1011 ] ]
    

    tho, from what I can grasp of the description (which is a bit convoluted, since you essentially rely on the examples to actually give hint about the underlying logic... Not really fond of that... ;/ )

    N: [[ 98, 57, 120, 181, 292, 361 ]]
    E: [[ 98, 1011 ]]
    W: [[ 98, 1011 ]]
    E: [[ 1109 ]]
    

    Other than that, two suggestions:

    • shouldn't printState rather be getState or currentState? (nothing is printed and the output isn't a string)
    • you should revert the order of the sample tests: the integration test after the unit tests.

    cheers, B4B

  • user9644768 Avatar
    [ [ 11, 11 ], [ 9, 8 ] ]
    EW
    expected [ [ 11, 11 ], [ 17, 0 ] ] to deeply equal [ [ 11, 11 ], [ 9, 8 ] ]
    

    After E:

    [[11, 11],
     [9,   8]]
    

    After W:

    [[11, 11],
     [17, 0]]
    

    Where I could be wrong?