jsacademyio / Data-Structures-And-Algorithms-Workshop

This is the repository for the Data Structures & Algorithms workshop
MIT License
2 stars 11 forks source link

Crossword #7

Open acha-bill opened 4 years ago

acha-bill commented 4 years ago

A 10x10 Crossword grid is provided to you, along with a set of words (or names of places) which need to be filled into the grid. Cells are marked either + or -. Cells marked with a - are to be filled with the word list.

For example. The following shows an example crossword from the input crossword grid and the list of words to fit, words = [POLAND, INDIA, SPAIN, LHASA]

Input           Output

++++++++++      ++++++++++
+------+++      +POLAND+++
+++-++++++      +++H++++++
+++-++++++      +++A++++++
+++-----++      +++SPAIN++
+++-++-+++      +++A++N+++
++++++-+++      ++++++D+++
++++++-+++      ++++++I+++
++++++-+++      ++++++A+++
++++++++++      ++++++++++
POLAND;LHASA;SPAIN;INDIA

You will be given: crossword: an array of strings of length representing the empty grid. words: a string consisting of semicolon-delimited strings to fit into crossword

Write a function that outputs the result of the crossword puzzle.

e.g

+-++++++++
+-++++++++
+-----++++
+-+++-++++
+-+++-++++
+++++-++++
++------++
+++++-++++
+++++-++++
LONDON;DELHI;ICELAND;ANKARA

//output
+L++++++++
+O++++++++
+N++++++++
+DELHI++++
+O+++C++++
+N+++E++++
+++++L++++
++ANKARA++
+++++N++++
+++++D++++

e.g

+-++++++++
+-++++++++
+-------++
+-++++++++
+-++++++++
+------+++
+-+++-++++
+++++-++++
+++++-++++
++++++++++
AGRA;NORWAY;ENGLAND;GWALIOR

//output
+E++++++++
+N++++++++
+GWALIOR++
+L++++++++
+A++++++++
+NORWAY+++
+D+++G++++
+++++R++++
+++++A++++
++++++++++