DEV Community

dev.to staff
dev.to staff

Posted on

5 1

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!

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay