• The positions of different chess pieces are given in a cell p .
  • The position of the king is given as x

Determine if the opponent king is in check for individual scenerios.

  • x='Kg7'
  • p={'Qe5','Qg5','Qb5','Qa7'}

output= [1,1,0,1]

N.b.any invalid position should produce 0. u may imagine p as the white pieces and x as the black king for clarity.

Solution Stats

26 Solutions

14 Solvers

Last Solution submitted on Oct 19, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers14

Suggested Problems

More from this Author174

Problem Tags

Community Treasure Hunt

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

Start Hunting!