Create the function `crosswordSolver` that is able to solve an empty crossword puzzle
Create the function `crosswordSolver` that is able to solve an empty crossword puzzle.
The function takes two arguments:
The function takes two arguments:
1. an empty puzzle, passed as a string and
1. an empty puzzle, passed as a string and
2. a list of words to fill in the puzzle (no double words allowed)
2. a list of words to fill in the puzzle (no double words allowed)
The function must return the puzzle filled with the input words.
The function must print on the console a string representing the puzzle filled with the input words.
The empty puzzle will be a string with the following rules:
The empty puzzle will be a string with the following rules:
- each character will be either a number, a `.` or a `\n`;
- each character will be either a number, a `.` or a `\n`;
- a number represent the number of words starting from the specific position and a `.` represent a space that does not need to be filled.
- a number represent the number of words starting from the specific position and a `.` represent a space that does not need to be filled.
If the puzzle or list of words provided as inputs does not guarantee a unique solution, or any other conditions stated above are not met, the function must return`'Error'`.
If the puzzle or list of words provided as inputs does not guarantee a unique solution, or any other conditions stated above are not met, the function must print`'Error'`.
##### Open the repository of the project and check the submitted files
##### Open the repository of the project and check the submitted files
###### Can you confirm that the `"crosswordSolver.js"` file is present and you can run the `"main.js"` provided?
###### Can you confirm that the `crosswordSolver.js` file is present and you can run the following comand `node crosswordSolver.js` adding the following lines to the original `crosswordSolver.js`?
```js
const puzzle = '2001\n0..0\n1000\n0..0'
const words = ['casa', 'alan', 'ciao', 'anta']
crosswordSolver(puzzle, words)
```
##### Try running the function with the arguments:
##### Try running the function with the arguments:
```js
```js
@ -15,7 +21,7 @@ anta
o..n
o..n
```
```
###### Does the function returns the value above?
###### Does the function displays the value above?
##### Try running the function with the arguments:
##### Try running the function with the arguments:
```js
```js
@ -65,9 +71,56 @@ bikini..r...n..
..........s....
..........s....
```
```
###### Does the function returns the value above?
###### Does the function displays the value above?
###### Does the function displays the value above?
##### Try running the function with the arguments:
```js
const puzzle =
`..1.1..1...
10000..1000
..0.0..0...
..1000000..
..0.0..0...
1000..10000
..0.1..0...
....0..0...
..100000...
....0..0...
....0......`
const words = [
'popcorn',
'fruit',
'flour',
'chicken',
'eggs',
'vegetables',
'pasta',
'pork',
'steak',
'cheese',
]
```
```
..p.f..v...
flour..eggs
..p.u..g...
..chicken..
..o.t..t...
pork..pasta
..n.s..b...
....t..l...
..cheese...
....a..s...
....k......
```
###### Does the function displays the value above?
##### Try running the function with the arguments:
##### Try running the function with the arguments:
[comment]: <> Test mismatch between number of input words and puzzle starting cells