You can check the details of this marathon match in topcoder site: https://www.topcoder.com/challenges/82eb883d-85e9-442f-b0eb-91631d3d2a8f?tab=details
Problem Summary
You are given a 2D grid containing few holes, number blocks and empty cells. Your task is to move numbered cells to any hole using Slide or Move operations. Along the way, your goal is to maximize game score based on certain defined rules.
My Approach
My approach was to use simulated annealing (SA). In every iteration of the SA, I swapped the position of two numbered cells from an ordered list of numbered cells. This ordered list represents the order in which I want to move/slide blocks to holes one by one and one at a time.
Now my score boosted up after few optimization on baseline SA.
- When you move a block to hole, move it using shortest number of operations.
- Instead of always choosing two random number blocks I fixed one index, which is the last number block index in previous iteration where the process stopped due to Z <= 1 (score multiplier, see description) or no way to move that block
- Instead of having a random initial order of blocks, I used a greedy approach to sort the block based on shortest moves first, then based on block value.
A demo of my solution for one of the test cases is below.
My code and along with other resources (including other competitor’s approaches) of this match can be found in my Topcoder repository
Here is another blog article on this match.
Some contestants used Beam Search in this match. Here is the wiki book link for that.