From 8d2d144070b5f954531b75c9b58ebe26b1da21db Mon Sep 17 00:00:00 2001 From: nprimo Date: Thu, 22 Sep 2022 14:22:54 +0100 Subject: [PATCH] docs(crossword): update subject and audit Clarify expected output in subject Add more checks in audit --- subjects/crossword/README.md | 27 +++++++-- subjects/crossword/audit/README.md | 93 ++++++++++++++++++++++++++---- 2 files changed, 102 insertions(+), 18 deletions(-) diff --git a/subjects/crossword/README.md b/subjects/crossword/README.md index 4ac65456..2d2c01d6 100644 --- a/subjects/crossword/README.md +++ b/subjects/crossword/README.md @@ -2,23 +2,38 @@ ### Instructions -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: 1. an empty puzzle, passed as a string and 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: - 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. -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'`. ### Examples ```js -console.log(crosswordSolver('2001\n0..0\n1000\n0..0', ['casa', 'alan', 'ciao', 'anta'])) -// output: 'casa\ni..l\nanta\no..n' -``` + +const emptyPuzzle = +`2001 +0..0 +1000 +0..0 +` +const words = ['casa', 'alan', 'ciao', 'anta'] + +console.log(crosswordSolver(emptyPuzzle, words)) +/* output: +` +casa +i..l +anta +o..n` +*/ +``` \ No newline at end of file diff --git a/subjects/crossword/audit/README.md b/subjects/crossword/audit/README.md index dadb7cfd..00d2baec 100644 --- a/subjects/crossword/audit/README.md +++ b/subjects/crossword/audit/README.md @@ -1,6 +1,12 @@ ##### 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: ```js @@ -15,7 +21,7 @@ anta o..n ``` -###### Does the function returns the value above? +###### Does the function displays the value above? ##### Try running the function with the arguments: ```js @@ -65,9 +71,56 @@ bikini..r...n.. ..........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: +[comment]: <> Test mismatch between number of input words and puzzle starting cells ```js const puzzle = '2001\n0..0\n1000\n0..0' const words = ['casa', 'casa', 'ciao', 'anta'] @@ -77,9 +130,10 @@ const words = ['casa', 'casa', 'ciao', 'anta'] Error ``` -###### Does the function returns the value above? +###### Does the function displays the value above? ##### Try running the function with the arguments: +[comment]: <> Test starting words higher than 2 ```js const puzzle = '0001\n0..0\n3000\n0..0' const words = ['casa', 'alan', 'ciao', 'anta'] @@ -89,9 +143,10 @@ const words = ['casa', 'alan', 'ciao', 'anta'] Error ``` -###### Does the function returns the value above? +###### Does the function displays the value above? ##### Try running the function with the arguments: +[comment]: <> Test words repetition ```js const puzzle = '2001\n0..0\n1000\n0..0' const words = ['casa', 'casa', 'ciao', 'anta'] @@ -101,9 +156,10 @@ const words = ['casa', 'casa', 'ciao', 'anta'] Error ``` -###### Does the function returns the value above? +###### Does the function displays the value above? ##### Try running the function with the arguments: +[comment]: <> Test empty puzzle ```js const puzzle = '' const words = ['casa', 'alan', 'ciao', 'anta'] @@ -113,9 +169,10 @@ const words = ['casa', 'alan', 'ciao', 'anta'] Error ``` -###### Does the function returns the value above? +###### Does the function displays the value above? ##### Try running the function with the arguments: +[comment]: <> Test wrong format checks ```js const puzzle = 123 const words = ['casa', 'alan', 'ciao', 'anta'] @@ -125,9 +182,10 @@ const words = ['casa', 'alan', 'ciao', 'anta'] Error ``` -###### Does the function returns the value above? +###### Does the function displays the value above? ##### Try running the function with the arguments: +[comment]: <> Test wrong format checks ```js const puzzle = '' const words = 123 @@ -137,10 +195,21 @@ const words = 123 Error ``` -###### Does the function returns the value above? +###### Does the function displays the value above? -#### Bonus +##### Try running the function with the arguments: +[comment]: <> Test multiple solutions +```js +const puzzle = '2001\n0..0\n1000\n0..0' +const words = ['aaab', 'aaac', 'aaad', 'aaae'] +``` -###### Visualizer +``` +Error +``` + +###### Does the function displays the value above? + +#### Bonus -###### Performance / Algorithm used to solve it +###### +Is the project using ... \ No newline at end of file