How to Find best Wall clocks in Pakistan?

Vitalhable
2 min readSep 2, 2020

--

Wall clock decor

On the wall of the majestic main venue of the 2008 Beijing Olympics, there are nine 3*3_ wall clocks, as shown above (to start, please adjust the position of the hands and pins according to the data entered). However, the Olympics gave everyone a chance to change the time of the above wall clocks to 12 o’clock (we only consider the hour hand) with the least amount of movement. However, each action is not arbitrary and we must change the wall clock according to the list given below. For each of the operations we give, we must perform the specified operation wall clock decoration, each wall clock rotated 90 degrees clockwise.

Input format

Your program reads in the standard 3*3 format with nine numbers 0–3. 0 is 12 points, 1 is 3 points, 2 is 6 points, and 3 is 9 points.

Output format

Your program needs to write standard output. Output the shortest sequence of motion operations that will make all the wall clocks point to 12 o’clock, separated by a space, and add a carriage return if there is a space at the end. This shortest operation needs to be the smallest of all shortest operations, i.e., select the smallest first number of operations. If the first operands are equal, then select the smallest second operand…. And so on. To be sure, this order of operations is unique.

When we were given this question, the first thing that came to mind was a straightforward violent simulation, and the violent way was to search. The data on this question is not great. Obviously deep or wide search is possible, but there are more constraints. We can start by taking an array and storing the changes needed for the question. There are four types of clocks, so the final time complexity of our search won’t be too high, and then we can open a nine-dimensional array and store the number of variations in each case.

--

--