Skip to content

Completed Graph-1#797

Open
pratikb0501 wants to merge 1 commit into
super30admin:masterfrom
pratikb0501:master
Open

Completed Graph-1#797
pratikb0501 wants to merge 1 commit into
super30admin:masterfrom
pratikb0501:master

Conversation

@pratikb0501

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Find the town Judge (Problem_1.py)

Strengths:

  • Correctly implements the indegree concept
  • Clean and readable code structure
  • Efficient use of Python list operations
  • Proper index conversion between 0-indexed array and 1-indexed labels

Areas for Improvement:

  • Consider adding comments explaining the indegree concept for better readability
  • Could add an early check: if trust is empty and n == 1, return 1 directly (though current solution handles this correctly anyway)

The solution is functionally equivalent to the reference solution and demonstrates solid understanding of the problem.

VERDICT: PASS


Ball in the Maze (Problem_2.py)

Strengths:

  • Clean BFS implementation with good variable naming
  • Correct rolling ball logic implementation
  • Proper use of deque for queue operations
  • Good comments and code organization

Areas for Improvement:

  1. Critical Bug: You mark cells as visited (maze[cr][cc] = 2) before rolling in all directions. This can cause issues when a ball rolls and returns to its starting position - that position won't be re-added to the queue even though it might be needed for other paths. Move the marking to after you've determined the ball stops at a new position.

  2. Code Duplication: The rolling logic is repeated. Consider extracting it into a helper function like roll_ball(cr, cc, direction).

  3. Edge Case Handling: The solution handles boundaries correctly during rolling, but the logic could be clearer with early returns or helper functions.

Suggested Fix:

if maze[nr][nc] != 2:
    q.append([nr, nc])
    maze[nr][nc] = 2  # Mark when adding to queue, not when popping

VERDICT: NEEDS_IMPROVEMENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants