## DEV Community is a community of 891,187 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

dev.to staff

Posted on

# Daily Challenge #196 - Flou

To play the game, you'll start with a gameMap, like this one:

```+----+
|.B..|    +,-,| --> The boundary of game map
|....|    B     --> The initial color block
|....|    .     --> The empty block
|..B.|    It is always a rectangular shape
+----+
```

The goal of the game is to move the blocks in a way that would fill in the empty spaces.

Moving Rules

• Each block can only move once.
• If it hits an obstacle, the block will make a 90 degree right turn. It will stop if it's path is still blocked.
• Specify the direction of movement for each color block (Left, Right, Up, Down).

Output

• Your output should be a 2D array.
• Each subarray should contain 3 elements: [rowIndex, columnIndex, diretion]. `rowIndex` and `columnIndex are 0-based, diretion should be one of "Left", "Right", "Up" and "Down".

For the gameMap above, the output should be [[0,1,"Down"],[3,2,"Up"]].

Not all testcases have a solution, if there is no solution, please return a boolean value false.

For the gameMap above: we can move block A downward, which would make it turn right once it hits the walls, and it will stop next to where we started. We can move B up for the same

```+----+
|aAbb|  # First colered block is designated 'A'
|aabb|
|aabb|
|aaBb|  # Second colored block is designated 'B', etc.
+----+
The output should be [[0,1,"Down"],[3,2,"Up"]].
```

Awesome, so now we have all the spaces colored. If you want to see a live version of this game, you can play it here: https://www.bgames.com/puzzle-games/flou/

### Tests

```+----+
|B...|
|....|
|....|
|....|
+----+

+----+
|.AB.|
|....|
|....|
|....|
+----+

+----+
|B...|
|A...|
|....|
|....|
+----+
```

Good luck!

This challenge comes from myjinxin2015 on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!

Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!