hmehta's blog

By hmehta, history, 5 years ago, In English

Topcoder MM 117 -  **RotatingNumbers** is now live!

Problem Setter: dimkadimon

Problem Testers: JacoCronje, kphmdKaasanErinnparanoia and wleite

Problem Statement: 
Given an NxN grid of numbers, your task is to move the numbers to their target locations. A number n at row r and column c (both 0-based) is in its target location if n = r*N + c + 1. A move consists of selecting a square subgrid and rotating all its numbers by 90 degrees clockwise or counterclockwise. Rotating a subgrid of size S (2 <= S <= N) incurs a penalty of floor((S-1)^1.5). A number that does not finish in its target location is penalized by P*dist, where P is a weighting input parameter and dist is the Manhattan distance to its target location. Your task is to minimize the total penalty.

Here is an example solution for seed=1 and N\=4. The subgrid currently being rotated is highlighted in blue for clockwise rotations and in red for counterclockwise rotations. The cells are painted green based on how close their number is to the target location.

Register Now!

Best of luck! 
- the Topcoder Team

  • Vote: I like it
  • +16
  • Vote: I do not like it