Programmer Puzzle: Encoding a chess board state throughout a game

前端 未结 30 1579
闹比i
闹比i 2021-01-29 17:16

Not strictly a question, more of a puzzle...

Over the years, I\'ve been involved in a few technical interviews of new employees. Other than asking the standard \"do you

30条回答
  •  面向向阳花
    2021-01-29 17:46

    There are 32 pieces on the board. Each piece has a position (one in 64 squares). So you just need 32 positive integers.

    I know 64 positions hold in 6 bits but I wouldn't do that. I'd keep the last bits for a few flags (dropped piece, queen'ed pawn)

提交回复
热议问题