Search [Enter] to search. Click anywhere to close.

February 2nd, 2021

4 Challenging Coding Problems To Solve

A big part of being a developer is problem solving. I think it’s a fair assumption to say that most of us enjoy this aspect of our craft — thinking outside the box whilst also applying the fundamentals to solve problems.

The coding exercises listed below will test your problem-solving abilities. The tasks are likely most suited to intermediate developers.

If you’re looking for shorter and more concise coding problems to solve that aren’t as time consuming — do feel free to check out my JavaScript Exercises for Beginners series, starting with Part 1: Strings.

During the exercises below, it’s important to consider: how efficient is my solution? Not all solutions are equal. For bonus points, your algorithm or solution should be as efficient as possible.

With that said, let’s look at the coding problems!

1. The crossword generator

Building a crossword generator in your language of choice certainly requires some forethought. If you’re looking for challenging coding problems to solve, this one could certainly be a good start!

What does it need to do?

To briefly summarize the required functionality, you’ll need to generate:

  • A square grid of x by x. This should be configurable, for extra points
  • A library of potential words & clues to populate this grid with
  • As many words as possible must fit into the grid — horizontal words and vertical words. The words must overlap one another as often as possible to make for an intriguing puzzle

With those three elements in mind, you’ll need to come up with a decent mechanism to dynamically compose a crossword of randomized words and layouts.

The user must then determine each of the words based on the provided clues. This part is optional — the algorithm to generate the crossword is already complete by this point.

Where is the complexity when solving this coding problem?

Your algorithm will need to effectively determine valid words from a starting library of words. It’ll then need to consider any matches with the currently-placed words, and the position of these entities.

Given this, you’ll need to select a specific word to place, hopefully leaving enough room and opportunity for more interesting configurations with the subsequent word choices.

The more starting words you have in your library to begin with, the easier the crossword layout will be to generate.

Can I make the coding problem a bit easier to solve?

This coding problem can be made much easier to solve by working to a specific structure. For instance, one long word placed vertically in the centre of the grid — with several shorter words branching off this in either direction.

If you’re struggling, starting with this approach may help you cognitively unlock some of the other mechanisms you need to advance your generator algorithm.

However, for maximum points, you’ll want a truly random layout — and something the resembles a real crossword.

2. The Sudoku generator

Most of us are probably somewhat familiar with the logic puzzle known as Sudoku, but if not — here’s a quick recap:

Sudoku is a logic-based, combinatorial number-placement puzzle. In classic sudoku, the objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid contain all of the digits from 1 to 9.


The idea of the Sudoku generator is simply to generate these puzzles for the users to solve. Each puzzle should be random and completely different to the last. A selection of numbers will at first be visible to the users; the rest of the numbers must be placed correctly in order to “win”.

Sudoku dates back to an 18th Century Swiss mathematician’s game “Latin Squares”

The difficulty or complexity of a Sudoku puzzle is determined by multiple factors. These factors must first be considered — and then built into your solution.

The most obvious factor to control the difficulty of this coding problem would be the number of starting digits. Beyond this, you’ll need to at first consider the techniques commonly used to solve Sudoku problems to begin with — this can get fairly complex.

With this in mind, the puzzle generator should have “Easy”, “Medium” and “Hard” modes, ideally.

3. The magic square solver

The premise of the magic square puzzle is simple: a square grid must be populated with numbers such that each row and each column will add up to the same total.

Building a magic square solver is a fairly challenging coding problem
Magic squares go back a long way (China, ~2200 BC)!

The larger the grid, the more complex the puzzle becomes and the more possible solutions there are. The smallest possible magic square grid would be a 3×3 one.

There are 8 possible solutions to the 3×3 grid (if you count rotations & reflections, otherwise it’s only 1!). Write an algorithm to locate each of these solutions.

Making the coding problem more complex

As stated, the main way to increase the complexity of this coding problem is to increase the grid size.

Will your previous algorithm work with a grid of 4×4? Every row and every column must sum to the same amount.

This time, there are a staggering 880 total solutions…

To get a better idea of the requirement here, there are existing tools out there already — such as this magic square generator/solver from

4. The word search generator

The classic word search puzzle: given a square grid of a predetermined size, the user must pick out “real” words amidst an array of random letters.

Isn’t this similar to the crossword generator?

Yes and no.

There are a few similarities here when compared with the crossword generator: words of varying length must be configured horizontally or vertically into the starting grid.

However, with the word search — words can also align diagonally into the grid. This certainly adds a degree of complexity.

That said, word matching functionality from the crossword generator (above) could definitely come in handy for this exercise.

Can I build an easier version of this coding problem to begin with?

Certainly, there are a few ways to make the crossword generator algorithm a little easier to digest to begin with:

  • Avoid diagonals entirely
  • Prioritize words in a specific direction (horizontal/vertical) and don’t focus on overlapping them at all

This would be a good first step.

Integrating diagonals and a mixture of horizontally/vertically positioned words may become easier to figure out with a functional starting point.

Where can I find more coding problems to solve?

There are a few different avenues you can explore to locate problems just like the ones listed in this article. Let’s cover the 3 most prominent ones.

Coding challenge websites

There are many sites out there that deal specifically with handing out these types of coding problem. You’ll find an abundance of coding problems to solve within these resources; ranging from fairly easy to very, very difficult.

Two of the more popular ones would be LeetCode and Codewars.

These sites typically have exercises spanning many different aspects of each specific language. You can pick your weakest areas and focus on those. The sites are a great tool for developers of all experience levels and abilities.

Tech giant interviews

Another great resource for this type of coding problem can be found on YouTube. There are many technical interviews out there with companies such as Airbnb, Google and so on. There are a great resource for actual learning — but they are also entertaining in their own right, usually, which is a bonus.

You’ll see another developer sitting in the hot seat. You’ll be able to listen to his or her reasoning when questioned by the interviewer regarding their (potential) solution to the coding problem at hand.

Studying the thought process of other developers is a great way to identify new techniques when it comes to implementing your own solutions.

Get creative – come up with your own coding problems to solve!

Outside of that, you can get creative and come up with your own coding problems.

You can come up with permutations that make existing coding problems more difficult or easier. Or you can figure out a completely new, original problem and then try to solve it yourself.

You are only limited by your own creativity in this regard.

In closing

I hope you enjoyed these coding problems and I hope you had fun solving them!

Be sure to check back later for more articles like this one. Though I write articles revolving around web & app development in a general sense — documenting logic problems and exercises is one of my favourite topics to cover.

If you’re looking for project ideas as opposed to logic problems (and their algorithmic solutions), you could check out some articles I’ve written on this very topic:

Thanks for reading!

Have any questions? Ping me over at @justacodingblog
← Back to blog