Most Students Without Copying
room is a classroom given as a list of rows of equal length, the front row first. A . is a working seat and a # is a broken one. A student can copy from the seats directly to their left and right, and from the two seats diagonally in front of them (front left and front right). Nobody can copy from the seat straight in front or straight behind.
Seat as many students as possible on working seats so that no student can copy from another. Return that number.
Example 1
Use the first and the last column in both rows. Nobody sits beside or diagonally in front of anybody.
Example 2
The two back seats can both be used. The front seat lies diagonally in front of each of them, so it stays empty.
Constraints
1 <= len(room) <= 81 <= len(room[0]) <= 6, and every row has that lengthroomholds only.and#
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Bits problems
- Numbers With K One BitsHard
- Numbers Without Neighboring OnesHard
- Smallest Team With Every SkillHard
- Split Powers to Hit a TotalHard
- Build a MaskBeginner
- Fixed Width BinaryBeginner
- Flip One BitBeginner
- Gray Code SequenceBeginner