IBM Research

PUZZLE   IBM-303

Sliding Pieces Game

IBM Research · Ponder This · 2023-07

IBM Ponder This #303 · July 2023

A game is played on a 2D board:

The board is represented here with X’s for blanks and the same number for every square of a given piece X112X
X122X
34556
74666

During every turn of the game, one piece is chosen and can be moved one step right, left, up or down, given enough free space in that direction.

The cost of moving a piece is 5s where s is the size of the piece, so moving a piece composed of four squares costs 1, while moving a piece of one square costs 4.

The goal of the game is to arrange the board according to some goal, with minimum cost.

Note that pieces of the same size and shape are considered identical.

For example, given the following goal for the original board above:

11XX2
14X22
34556
X7666

The sequence of steps reaching the goal from the beginning is:

X112X
X122X
34556
74666

11XX2
1XX22
34556
74666

11XX2
14X22
34556
X7666

11XX2
14X22
34556
7X666

11XX2
14X22
34556
X7666

The cost of the first 2 moves is 2, the third one is 3, and the last one is 4, totaling 11.

Given a board, a compact way to describe a solution is to number all the pieces, and then write a string of the form "3U5L" etc. to denote moves (first the number of the shape, and then the direction: U=Up, L=Left, R=Right, D=Down).

For the above board, we can use the following numbering:

X112X
X122X
34556
74666

So the solution is written as the following:

"1L2R4U7R"

Your goal Starting from this initial board:

12234
12334
56778
99888
XXXXX

Find a solution with a cost of no more than 100 that reaches the following goal:

77X22
XX321
X3341
59948
X6888

A bonus "*" will be given for finding a solution with a cost of no more than 150 which, using the same initial board, reaches the following goal:

X223X
12338
1X888
4XX56
49977

Solution

Best opened after a real attempt

To be added.