Ad
  • Custom User Avatar

    Priority goes to the Power Gem with higher elevation, so in your example the first case would be the correct result.

  • Default User Avatar

    So after reading all of the other questions, and not really finding an answer to the one I had, I thought I'd ask it

    In the context of Power Gems
    What would the power gem look like in the following situation

      RRR
    RRRRR
    RRRRR
    

    if the formed power gems look like

      S11
    22S11
    22S11
    

    1's and 2's being the power gem id and the S's being single.
    The explanation of the game mentioned how when power gems are formed, the higher elevation takes priority, and when a gem wants to 'grow' it tries to form a new power gem and then combine with others at the same level, but what if the gems are already formed, and there are 2 options for 'growing'?

    Would the formation of power gems look like

      111
    22111
    22111
    

    or

      S11
    22211
    22211
    

    assuming they are the same color

  • Default User Avatar

    Damn, now thats some optimization.

  • Custom User Avatar

    I picked the closest solution I had - mine. In fact, I improved my old and bad algorithm and managed to get a 2x increase in execution speed (tested with the same input as in the previous fork).

  • Default User Avatar

    Ahh, I hadn't seen your solution, I was just looking at the ones that were rated best solution. But I knew my solution wouldnt have been BEST, but I'm glad to see your solution, hopefully it will help me with optimizing in the furute!

  • Custom User Avatar

    Not really. Tested on greater input values, your solution is degrading faster (press View Run Output, and you should see 2 collapsed blocks; open them and you'll see the execution time).

  • Default User Avatar

    What language are you using?

  • Default User Avatar

    I think they use 0 and . in the description because its easier to read, but the code works the same.
    I think the reason for 0's and 1's are for the boolean true and false comparison someone could use in their code.
    I mean, it still works, I got mine down to 651 ms.

  • Default User Avatar

    Looking at the other solutions, mine seems to be faster than others.
    Normally I'm struggling to make it in the time limit, I'm terrible at optimizing.
    This was my first code to run faster than the other people I've looked at!

  • Default User Avatar

    yes, the performance tests were completely wrong..... I corrected them, your solution should be marked as invalid soon.

  • Default User Avatar

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