CHALLENGE
Given a set of grouped letters, arrange them onto the board so that they cover the area entirely.
Board Representation (a.k.a. the SHIP DECK)
- The board is a 6x6 grid.
- There will always be 36 total squares.
- Columns are marked A-F.
- Rows are marked 1-6.
Example:
A B C D E F
+---+---+---+---+---+---+
1 : : : : : : :
+---+---+---+---+---+---+
2 : : : : : : :
+---+---+---+---+---+---+
3 : : : : : : :
+---+---+---+---+---+---+
4 : : : : : : :
+---+---+---+---+---+---+
5 : : : : : : :
+---+---+---+---+---+---+
6 : : : : : : :
+---+---+---+---+---+---+
INPUT (a.k.a. the CRATES)
- A multiline string containing the set of grouped letters.
- Crates are made from the groups of identical letters.
- The crates are IMMUTABLE, meaning they can't be rotated or flipped.
- The starting point for each crate is on the top left (should be taken into account when moving a crate onto the deck).
- From the top left point of a crate, the following identical squares can only be to the right or below.
- Any letter can be used to represent a crate. The crates always start at letter
[a]
and move up the alphabet. - Crates are labeled by their letter (i.e. crate A, crate B, etc.)
- The number of crates can vary (it isn't always 10, despite the examples given).
- There are 24 characters separating each block of crates per line. (start of [a] to start of [b] separated by 24 characters, etc.)
Example:
[a][a][a] [b] [c][c]
[a] [b][b][b] [c]
[a] [b][b]
[d] [e] [f][f][f][f][f]
[d][d] [e]
[d][d] [e]
[e]
[e][e]
[g] [h] [i]
[g] [i]
[i]
OUTPUT
It is required that you print out a series of commands that place the crates in positions on the deck so that it is covered completely (no empty spaces).
The command format is like so:
HAUL <crate> TO <column> <row>
i.e. HAUL E TO A 1
For clarification, there will always be a solution for the input given.
TEST CASES <-- Click for more.
Input
[a][a][a] [b] [c][c][c]
[a][a] [b]
[a] [b][b]
[b][b]
[d] [e] [f]
[d] [f]
[d] [f]
[d]
[d]
[g][g] [h] [i]
[i][i]
[i]
[i][i]
[j][j][j]
Output
HAUL I TO A 1
HAUL B TO A 3
HAUL A TO B 1
HAUL J TO D 6
HAUL D TO F 1
HAUL F TO E 1
HAUL C TO C 5
HAUL G TO D 4
HAUL E TO D 3
HAUL H TO C 6
Result:
A B C D E F
+---+---+---+---+---+---+
1 : i : a : a : a : f : d :
+---+---+---+---+---+---+
2 : i : i : a : a : f : d :
+---+---+---+---+---+---+
3 : b : i : a : e : f : d :
+---+---+---+---+---+---+
4 : b : i : i : g : g : d :
+---+---+---+---+---+---+
5 : b : b : c : c : c : d :
+---+---+---+---+---+---+
6 : b : b : h : j : j : j :
+---+---+---+---+---+---+
SCORING
This is code-golf so the shortest answer in characters wins.