# [Community Puzzle] Crossword

https://www.codingame.com/training/medium/crossword

Created by @Humanosaure,validated by @IAmNoob,@CarlWalsh and @wlesavo.
If you have any issues, feel free to ping them.

Nice double problem. For me, print the solution was more complex than find them.

4 Likes

Hi Caduchon, do you have some hint for this? I canât think of a way to find the solutions.
I was thinking to start by finding all the intersections but then itâs not clear to me what to do with them in very complex cases. Thank you.

Search the letters that match.

Hi nicola, yes thank you, that is what I meant for âintersectionsâ, Iâve already got to that part. What is not clear to me is how you can determine the different solutions once you have all the letters that match.

Use brute-force.
There are only 4 ways to build a â#â by 2 horizontal and 2 vertical lines. Try out all of them to find the only way to make 4 common joints.

4 Likes

Yes, brute force.
My solution contains 4 for nested loops.

1 Like

Iâd think about what it means to be a match, ie what is the criteria. Finding intersections are a good idea, thatâs what I did and using the different sets of intersections, I went from there.

Hey there
Thanks for the puzzle.

I sadly have a problem, hope you can help and maybe specify.

in test case 12 I get the result:

``````........C..
.AWAAAAAXAA
BBYBBBBBZB.
..D.....C..
..D.....C..
..D........
``````

But I get the message:

### Failure

Found:
âŚCâŚ
Expected:
0

should there be a condition that h1 comes before h2 and v1 left from v2?`Preformatted text`

The two horizontal words must be at least one row apart from each other.

If you donât follow this rule you create multiple 2 letter words in the crossword grid as well as adding the words you were meant to add.

3 Likes

@RoboStac thanks, that helps.
Thought 1 row apart meant ânot in the same rowâ but this makes a lot of sense!

This puzzle is great ! Handling the indexes drove me mad, but it was good
My solution nests 6 for loops. Maybe someone smart could rephrase it with 4 loops but it does not seem obvious.

1 Like

Great puzzle. I tried a recursive approach but wasnât very successful, ended up nesting loops like everyone

1 Like

One of my dirties solutions for sure.
For the output part I went nobrain, ended up putthing everything in a matrix with w, h = len(h1)+len(h2), len(v1)+len(v2) to make sure the dimensions are big enough,
and THEN killing empty rows and columns to adjust.

IMO this problem should belong to the Hard section.

2 Likes

Super cool puzzle! Well done @Humanosaure! For anybody looking to eliminate some of those nested for loops, see if your language has a pre-built cartesian product function. Pythonâs itertools.product helped me clean things up a bunch.