Count the peaceful queens - MATLAB Cody - MATLAB Central

Problem 54770. Count the peaceful queens

Difficulty:Rate
In a 5x5 chessboard with a queen of one color (white, say) on the perimeter, one can place 12 black queens on the board such that none of the black queens can attack the white one (or vice versa).
Write a function that returns the number of queens that cannot attack a queen of the other color placed anywhere on the perimeter of an nxn chessboard.

Solution Stats

65.18% Correct | 34.82% Incorrect
Last Solution submitted on Apr 30, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

Chess Image
Chess
  • 18 Problems
  • 4 Finishers

Problem Recent Solvers66

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!