Tech News
← Back to articles

Solving LinkedIn Queens Using Haskell

read original related products more articles

June 24, 2025 · Agnishom Chattopadhyay

[Thanks to James Haydon for his suggestions on improving the post and the code quality]

On LinkedIn, you can play a variant of the N-Queens problem. A community version of the game (rather, puzzle) can be found here.

Recently, we saw it solved using SAT solvers, using SMT Solvers, using APL and MiniZinc. Today, I will try solving it using Haskell, a slightly more conventional language.

The Puzzle

You are given a N-colored square-shaped board of size N. You must place N queens on the board such that:

Each row, each column, and each color region has exactly one queen.

No two queens touch each other diagonally.

Note that placing two queens in the same diagonal is acceptable, as long as they are not diagonally adjacent (unlike in Chess).

For instance, one can verify that the following is the only solution for the given colored board.

... continue reading