Loader logo

Activity 4.3.1: Terminus - Part 2 May 2026

while (row, col) != goal and steps < max_steps: # Right-hand rule: try to turn right first for turn in [1, 0, 3, 2]: # right, straight, left, u-turn new_dir = (direction + turn) % 4 dr, dc = dirs[new_dir] new_row, new_col = row + dr, col + dc if (0 <= new_row < len(grid) and 0 <= new_col < len(grid[0]) and grid[new_row][new_col] == 0): # Move row, col = new_row, new_col direction = new_dir path.append((row, col)) visited.add((row, col)) break steps += 1

row, col = start path = [(row, col)] visited = set() visited.add((row, col)) activity 4.3.1: terminus - part 2

if (row, col) == goal: print(f"Goal reached in {steps} steps!") return path else: print("Goal unreachable or loop detected.") return None grid_example = [ [0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0] ] while (row, col)

It sounds like you're referring to a specific activity or module — possibly from a textbook, an online course (like zyBooks, CodeHS, or Project STEM), or a game-based learning platform. “Terminus” often appears in exercises where you navigate through a grid or solve a puzzle using loops and conditionals. col) != goal and steps &lt