Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
114 lines (74 sloc) 2 KB
Given a block of text, we can split it into geometric pieces
by using a template, the 'Split Pattern'.
* Example-1
Given the text "HELLO, WORLD!" and the split pattern AB, the
text would be split into two pieces.
"HELLO," for A
"WORLD!" for B
* Example-2
Given the text "HELLO, WORLD" and the split pattern AABBCC,
the text would be split into three pieces.
"HELL" for A
"O, W" for B
"ORLD" for C
If the input is a matrix (several lines) the split pattern is
applied onto the whole as one matrix.
* Example-3
Given the text "HELLO and the split pattern AB, the text
WORLD"
would be split into two pieces.
"HE for A
WO"
"LLO for B
RLD"
* Example-4
Given the text "HELLO and the split pattern A the text
WORLD" B
would be split into two pieces.
"HELLO" for A
"WORLD" for B
* The task
Write a program - that given a block of text, and a split pattern,
will split the text into the appropriate geometric parts, with the
appropriate contents.
The rules for the Split Pattern are
* No same letters may appear with another letter in between.
Thus, this is a legal pattern
AB
AB
AB
and this is NOT a legal pattern
AB
CB
AB
* Only choerent rectangles or squares of the same letters are allowed
Thus, this is a legal pattern
AAB
AAB
and this is NOT a legal pattern
AAB
AAB
BBB
* The split pattern must be an non-jagged matrix.
Thus, this is a legal pattern
ABB
CCC
and this is NOT a legal pattern
ABB
CC
* The dimensions of the pattern may never be greater than the dimensions of the
text itself: Meaning, neither the amount of columns, or rows may be greater
than the amount of rows and columns in the text.
Given "HELLO - the dimensions of the text are (2 5) 2 rows, 5 columns
WORLD"
Thus, this is a legal pattern
AB
and this is a legal pattern
A
B
and this is NOT a legal pattern (3 1)
A
B
C
likewise, this is also NOT a valid pattern (1 6)
ABCDEF