Online Chess Move Validation
Reported by candidates from OpenAI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The edge case that kills most answers on this OpenAI question is the pin, where a piece moves legally on paper but exposes its own king. OpenAI candidates reported Online Chess Move Validation in October 2026. You simulate moves from the standard start, return LEGAL or ILLEGAL per attempt, then dump the final board. It's a simulation problem with no clever algorithm, just a lot of rules to get exactly right. If you blank on the check logic mid-assessment, StealthCoder runs invisibly on your desktop and can hand you the structure while the proctor sees nothing.
The problem
Simulate move attempts from the standard initial chess position. White moves first. Each string in moves contains an origin square followed by a destination square in lowercase file-rank notation, such as e2e4. For each attempt, append LEGAL or ILLEGAL to the result. An illegal attempt leaves the board and turn unchanged. An accepted move changes the board and passes the turn. Use ordinary movement for kings, queens, rooks, bishops, knights, and pawns. Sliding pieces may not jump. A pawn may move one empty square forward, move two empty squares from its starting rank when the intermediate square is empty, or capture one opposing piece diagonally forward. A move may not capture a king or leave the moving side's king in check. Castling, en passant, promotion, clocks, draw rules, and checkmate adjudication are outside this exercise; a pawn move onto the last rank is illegal. Examples Example 1 moves = ["e2e4","e7e5","g1f3"] return = ["LEGAL","LEGAL","LEGAL","rnbqkbnr","pppp.ppp","........","....p...","....P...",".....N..","PPPP.PPP","RNBQKB.R"] Both king pawns advance, then White's knight jumps from g1 to f3. The eight trailing strings encode the resulting board.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to split validation into two layers. First, pseudo-legal: does the piece's movement rule allow this move, with sliders blocked by occupied squares, pawns moving straight only into empty squares, and captures only diagonal onto an opposing piece? Second, apply the move on a copy of the board and scan whether the mover's king is attacked. If it is, reject. That one check handles pins, moving into check, and failing to escape check. Common pitfalls: letting a pawn capture straight ahead, letting a pawn jump on its double step, allowing capture of a king, forgetting that a pawn reaching the last rank is illegal here, and mutating the board before you know the move is legal. Also check origin has a piece of the side to move. StealthCoder is your hedge in the live OA if the attack-detection function trips you up, but write the two-layer structure first.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Online Chess Move Validation cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass OpenAI's OA.
OpenAI reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Online Chess Move Validation FAQ
What's the trick to Online Chess Move Validation?+
Separate movement rules from king safety. Generate whether the move is pseudo-legal, apply it on a copy, then test if your own king is attacked. One attack function covers pins, check evasion, and illegal king moves. Don't try to special-case each situation.
How hard is this OpenAI OA question really?+
The logic is easy, the volume is the problem. There's no advanced algorithm, but six piece types and several pawn rules mean small bugs pile up. Expect to spend most of the time on pawns and check detection, not on the board loop.
What edge cases should I test before submitting?+
Test a pinned piece moving off its line, a king stepping onto an attacked square, a pawn double step through a blocked square, a pawn capturing straight, moving the opponent's piece, a move from an empty square, capturing a king, and a pawn reaching the last rank.
Do I need castling or en passant?+
No. The statement says castling, en passant, promotion, clocks, draw rules, and checkmate adjudication are outside the exercise. A pawn move onto the last rank is simply illegal. Skip all of it and keep the code small.
How do I prepare in 48 hours?+
Write a clean board class with a move validator, an is_attacked(square, side) function, and a board printer matching the output format. Run the sample e2e4, e7e5, g1f3 and check the eight trailing board strings. Then test illegal moves leave turn and board unchanged.