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

What is MCP? No, Really!

See MCP in action and explore how MCP decouples agents from servers, allowing for seamless integration with cloud-based resources and remote functionality.

Watch the demo

Top comments (0)

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

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server ⏰

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay