Crossword
Statement
Goal
Given two horizontal words (H1, H2) and two vertical words (V1, V2), find out if they can be printed so that they all intersect two by two.Each horizontal word must cross both vertical words.
Each vertical word must cross both horizontal words.
Words cannot be side by side:
The two horizontal words must be at least one row apart from each other.
The two vertical words must be at least one column apart from each other.
If there is one and only one solution, print out the crossword grid with dots "
Otherwise, print the number of solutions (could be zero).
The grid shall be adjusted to its minimal size.
Input
Line 1: A horizontal word H1
Line 2: A horizontal word H2
Line 3: A vertical word V1
Line 4: A vertical word V2
Line 2: A horizontal word H2
Line 3: A vertical word V1
Line 4: A vertical word V2
Output
The crossword grid if there is one and only one solution.
The number of solutions otherwise.
The number of solutions otherwise.
Constraints
1 ≤ length of each word ≤ 12
Example
Input
SIN BUT SOB NOT
Output
SIN O.O BUT
Tags
Strings, Permutations, Ascii Art
Difficulty
Medium
Test cases
Byte-sized philosophy Test
Input
SIN
BUT
SOB
NOT
Output
SIN
O.O
BUT
Validator 1 Validator
Input
BUT
SIN
NAT
SAB
Output
SIN
A.A
BUT
Color mix Test
Input
GREEN
YELLOW
ORANGE
INDIGO
Output
.O..I.
GREEN.
.A..D.
.N..I.
.G..G.
YELLOW
Validator 2 Validator
Input
YELLAW
GREEN
INDIGA
ARONGE
Output
.A..I.
GREEN.
.O..D.
.N..I.
.G..G.
YELLAW
Crime scene Test
Input
HEIST
ROBBERY
MONEY
THEFT
Output
....T..
.M..H..
ROBBERY
.N..F..
HEIST..
.Y.....
Validator 3 Validator
Input
RABBERY
HEIST
THEFT
MANEY
Output
....T..
.M..H..
RABBERY
.N..F..
HEIST..
.Y.....
Fruit salad Test
Input
PINEAPPLE
BANANA
LEMON
RASPBERRY
Output
....R...L.
PINEAPPLE.
....S...M.
....P...O.
....BANANA
....E.....
....R.....
....R.....
....Y.....
Validator 4 Validator
Input
BONONO
PINEOPPLE
ROSPBERRY
LEMAN
Output
....R...L.
PINEOPPLE.
....S...M.
....P...A.
....BONONO
....E.....
....R.....
....R.....
....Y.....
French writers 17th century Test
Input
CORNEILLE
BOILEAU
RACINE
MOLIERE
Output
..M......
..O......
..L..R...
BOILEAU..
..E..C...
CORNEILLE
..E..N...
.....E...
Validator 5 Validator
Input
BAILEOU
CARNEILLE
MALIERE
ROCINE
Output
..M......
..A......
..L..R...
BAILEOU..
..E..C...
CARNEILLE
..E..N...
.....E...
Marvel Series Test
Input
JESSICAJONES
DAREDEVIL
LUKECAGE
IRONFIST
Output
......L.....
......U.....
......K.....
.DAREDEVIL..
......C.R...
JESSICAJONES
......G.N...
......E.F...
........I...
........S...
........T...
Validator 6 Validator
Input
DOREDEVIL
JESSICOJANES
IRANFIST
LUKECOGE
Output
......L.....
......U.....
......K.....
.DOREDEVIL..
......C.R...
JESSICOJANES
......G.N...
......E.F...
........I...
........S...
........T...
French Coding Game Menu Test
Input
ENTRAINEMENT
COMPETITION
CONTRIBUTION
APPRENDRE
Output
19
Validator 7 Validator
Input
CAMPETITIAN
ENTROINEMENT
OPPRENDRE
CANTRIBUTIAN
Output
19
No Way ! Test
Input
THIS
TEST
RETURNS
ZERO
Output
0
Validator 8 Validator
Input
TEST
THIS
RETURNS
ZERA
Output
0
Crash Test Test
Input
A
A
A
A
Output
0
Validator 9 Validator
Input
O
O
O
O
Output
0
Base case test Test
Input
AWAAAAAXAA
BBYBBBBBZB
CXCCZ
WDDYD
Output
........C..
.AWAAAAAXAA
..D.....C..
..D.....C..
BBYBBBBBZB.
..D........
Validator 10 Validator
Input
BBYBBBBBZB
OWOOOOOXOO
WDDYD
CXCCZ
Output
........C..
.OWOOOOOXOO
..D.....C..
..D.....C..
BBYBBBBBZB.
..D........
Proximity test Test
Input
AXWAAAAAXAA
BBZYBBBBBZB
CZXCCZ
YWDDYD
Output
.........C..
...Y.....Z..
.AXWAAAAAXAA
...D.....C..
...D.....C..
BBZYBBBBBZB.
...D........
Validator 11 Validator
Input
OXWOOOOOXOO
BBZYBBBBBZB
YWDDYD
CZXCCZ
Output
.........C..
...Y.....Z..
.OXWOOOOOXOO
...D.....C..
...D.....C..
BBZYBBBBBZB.
...D........
No match test Test
Input
AWAAAAAXAA
BBYBBBBBZB
CXZCC
WYDDD
Output
0
Validator 12 Validator
Input
BBYBBBBBZB
OWOOOOOXOO
WYDDD
CXZCC
Output
0
Multiple solutions test Test
Input
AWAAAAAXAXA
BBYBBBBBZBZ
CXCCZ
DWWDYYD
Output
4
Validator 13 Validator
Input
BBYBBBBBZBZ
OWOOOOOXOXO
DWWDYYD
CXCCZ
Output
4
Solution language
Solution
Stub generator input