Open the context
Choose the project folder and name the files or behavior involved.
Trace four diagonal rays from one of 64 board squares through an unsigned 64-bit occupancy mask. Test corners and immediate blockers, including the first blocker but rejecting invalid integers without claiming complete move legality.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def diagonal_rays(square, occupied):
if type(square) is not int or not 0 <= square < 64 or type(occupied) is not int or not 0 <= occupied < 2**64:
raise ValueError("rays.input")
row, column = divmod(square, 8)
result = 0
for dr, dc in ((1, 1), (1, -1), (-1, 1), (-1, -1)):
r, c = row+dr, column+dc
while 0 <= r < 8 and 0 <= c < 8:
bit = 1 << (8*r+c)
result |= bit
if occupied & bit:
break
r, c = r+dr, c+dc
return result
The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.