Ad
  • Custom User Avatar

    That's awesome news, congrats on solving it!

  • Custom User Avatar

    Thank you, B1ts, I solved it! But I'm not sure whether it handles everything correctly. Tests are random... Anyway, can't way to see others' solution 8-)

  • Custom User Avatar

    ok, replying myself: I've just passed example tests, and the step-by-step debug info works for real tests.

  • Custom User Avatar

    Python translation: uncommenting see_states = True doesn't seem to work (I'm only told my solution was wrong and the expected final answer, but no step-by-step info to help me debugging), at least for tests (I did not submit my solution). Or, is it designed to work with "real" test cases only so I have to debug the example tests on my own?

  • Custom User Avatar

    ahhhh... you're right! I misread this part. Thank you!

  • Custom User Avatar

    I thought it only destroy itself if it LANDS on a gem of its color

    That would be rainbow gem. Crash gems trigger around it too. In your given board, it would destroy RR on left, and if B was R, it would clear the entire board at once.

  • Custom User Avatar

    No, because as soon as it touches another gem of its color (if another gem lands next to it), no matter if powergem or not, everything around it gets destroyed (including itself ofc).

    huh? I thought it only destroy itself if it LANDS on a gem of its color. What about this:

    R
    RrB
    

    First, rB lands on the ground on step 1, then a vertical pair RR lands immediately to its left on step 2. Will r destroy BB to its left and also destroy itself in step 2? If no, then we can throw another vertical RR on r then theoretically we got a 2x2 red gem containing one crash gem.

    Btw, there's 1 tip that I can give you, and it's that the tests are very thorough and you have to account for every possibility. You may think you could take some shortcuts, or avoid certain situations, but it won't work. Soon enough, you can end up with a lot of spaghetti code :P

    Oh, thanks! Then I'm giving myself an additional challenge to minimize the time spent from submitting my first solution to solving this problem 8-)

  • Custom User Avatar

    S,1,2 are all red gems, so they cannot merge with Green gems. So maybe 1 expand left one, 2 cannot expand?

    Yeah, seems correct.

    can crash gems be part of a power gem?

    No, because as soon as it touches another gem of its color (if another gem lands next to it), no matter if powergem or not, everything around it gets destroyed (including itself ofc).

    Btw, there's 1 tip that I can give you, and it's that the tests are very thorough and you have to account for every possibility. You may think you could take some shortcuts, or avoid certain situations, but it won't work. Soon enough, you can end up with a lot of spaghetti code :P

  • Custom User Avatar

    Another small question: can crash gems be part of a power gem? I think not, but I can't find a clear rule about it. Technically, a crash gem also has a color anyway.

  • Custom User Avatar

    Oops, I was in a hurry when replying the last time, and now that I found I didn't make it clear that in my last example, S,1,2 are all red gems, so they cannot merge with Green gems. So maybe 1 expand left one, 2 cannot expand? Anyway, I'll try myself soon, and thanks again!

  • Custom User Avatar

    Thank you! I'll try.

  • Custom User Avatar

    It's been some time since I solved it, but from what I remember, first all non-powergem pieces form gems, if possible (top to bottom, left to right), then merging single pieces with gems (horizontally first, then vertically), then merging gems with other gems.

    I'm not sure how to interpret that first board, but if I understood correctly, then 1 would expand left once, then 2 would merge with G (horizontal growth priority)

    And yes, merging can occur many times: in your second board, 1 would merge with S on left AND right side, then it would merge with gem2 to form 1 massive powergem.

    At least that's how I remember these interactions, I could be wrong :D

    Edit: for the first board, let's say those S weren't there. I think 2 would merge first, even though 1 is higher, because of horizontal growth first, as mentioned previously.

  • Custom User Avatar

    Thanks! That's very clear. Just to confirm: Power gems are processed from top to bottom, left to right? For example:

    000000
    000S11
    00SS11
    0022GG
    0022GG
    

    We process 1 first, so 1 is able to expand, but 2 cannot. If we process 2 first then only 2 can expand.

    Also, merging can take several steps, like this?

    S11S
    S11S
    2222
    2222
    

    1 first expands to left and right, then expand down so all of them merge into a giant power gem?

  • Custom User Avatar

    In your given board, none of them will merge. For power gems to merge, they should have same exact height (if you want to merge horizontally), and start at same elevation. (similar with vertical merging)

    For example: 0 - empty place, 1,2 - power gems (let's assume all non-0s are red)

    0000000
    0000000
    0000000
    1122222
    1122222
    

    1 would merge with 2. But in case of:

    0000000
    0000000
    0022222
    1122222
    1122222
    

    No merge would happen, because heights are different. Here's an example of successful vertical powergem merge:

    0000000
    0002200
    0002200
    0001100
    0001100
    

    Last example of singles merging with a powergem: (S - non-powergem pieces)

    0000000
    0002200
    0002200
    00011S0
    00011S0
    

    Singles will merge with powergem 1, and that's it (no merge with 2)

    Does that make it any clearer? TBH you have to read the rules many times to understand exactly how it works.

  • Custom User Avatar

    This is an intersting problem and I've already started coding. However, it's not very clear to me that how to expand exsiting Power Gems. Suppose the following board just after dropping the pair (I don't know whether it's a reachable state, but...)

    0000033
    0000033
    0000033
    0011133
    2211133
    2211133
    

    All the gems are red, the number denotes the id of power gems (0 are indivial, 1 is the 1st power gem, 2 is the 2nd power gem). After merging individual gems:

    4444433
    4444433
    4444433
    0011133
    2211133
    2211133
    

    Now, will all the gems (2 individual gems + 4 power gems) merge into a giant power gem? If not, what's the exact rule of merging? Thanks!

    EDIT: board in the last edition was wrong...