- All colours are connected to their respective identical colour, in a continuous path and without overlaps or crossovers.
A higher resolution is required to access the IDE
- 2
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
The Goal
Connect the Colours is a logical puzzle that involves connecting pairs of matching colours in a closed grid.
The objective is to connect ALL pairs of identical colours with non-overlapping paths, using EVERY tile.
This is the second edition of the "Connect the Colours" series. This edition does NOT contain any of the special tiles that are in part 1.
This is the second edition of the "Connect the Colours" series. This edition does NOT contain any of the special tiles that are in part 1.
Rules
- Paths must consist of one or more horizontal and/or vertical segments to connect adjacent tiles.
- Each colour must be connected to the other instance of the same colour using a continuous path.
- A single tile can only be used in ONE path and any two paths CANNOT overlap or cross each other.
- Paths must remain entirely within the grid boundaries.
- Every tile must be used in a path, so that there are no empty tiles remaining.
Victory Conditions
Loss Conditions
- Response time exceeds the time limit.
- The output is not properly formatted.
- Attempted to create an invalid path.
- Number of turns exceeds the turn limit.
🐞 Debug Mode
Enable the debug mode using the settings icon to provide extra information when hovering over tiles in the viewer.
Game Input
Input
Line 1: Space separated integers h w representing the height and width of the puzzle.
Next h Lines: String of length w representing a row of the puzzle.
Integers are used to define colours. Matching integers represent the same colour.
The full stop character (
Output per turn
A single line containing space-separated integers in the form x1 y1 x2 y2 colour.
Tiles MUST be in the same plane either horizontally or vertically (x1 = x2 OR y1 = y2).
- x1 - X-Coordinate of the first tile.
- y1 - Y-Coordinate of the first tile.
- x2 - X-Coordinate of the second tile.
- y2 - Y-Coordinate of the second tile.
- colour - Colour identifier.
Tiles MUST be in the same plane either horizontally or vertically (x1 = x2 OR y1 = y2).
Example
Initialization input
3 3 (h,w) 1.2 (row)
... (row)
.12 (row)
Grid with 3 rows and 3 columns. Integers in the rows represent the two tiles of a specific colour that must be connected with a single continuous path.


Output for turn 1
0 0 0 2 1
Create a path from coordinates (0 ,0 ) to the coordinates (0 ,2 ) using the colour represented by the colour identifier 1 .


Output for turn 2
2 0 1 0 2
Create a path from coordinates (2 ,0 ) to the coordinates (1 ,0 ) using the colour represented by the colour identifier 2 .


Outputs for remaining turns
0 2 1 2 11 0 1 1 2
1 1 2 1 2
2 1 2 2 2
Create paths for the remaining paired tiles, ensuring that each colour is connected by a single continuous path and that every tile is used.


Constraints
1 ≤ h, w ≤ 20
A colour identifier will appear exactly twice within a puzzle.
Maximum number of distinct colours in a puzzle is9 .
Allotted response time for first output is2 seconds.
Allotted response time for subsequent outputs is50 ms.
Turn limit is60 turns.
A colour identifier will appear exactly twice within a puzzle.
Maximum number of distinct colours in a puzzle is
Allotted response time for first output is
Allotted response time for subsequent outputs is
Turn limit is
A higher resolution is required to access the IDE