Neural Sync Active
jan-2026-python-week-7-numbers-3
Registry Synced
jan-2026-python-week-7-numbers-3
732 words
4 min read
Numbers 3
Course: Jan 2026 - Python
Numbers 3
Submission deadline has passed for this assignment
Due Apr 01, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
3/3 Passed
Submitted on Apr 01, 2026 at 3:46 AM IST
Private Tests
3/3 Passed
Submitted on Apr 01, 2026 at 3:46 AM IST
**Change in eligibility criteria to write oppe2 exam: A5>=40/100 AND A6>=40/100 AND A7>=40/100 AND A8>=40/100. and becoming eligible to give the end term exam.
Find Manhattan distance between two 2d points through a point**
Given three points a, b, and c on the Cartesian plane, calculate the Manhattan distance to go from point a to point c via point b.
Manhattan distance is the sum of the absolute differences of their Cartesian coordinates.
Template Code(Click to Expand)
def manhattan_distance_via_b(a: tuple, b: tuple, c: tuple) -> int: ''' Given three points a, b, and c on the Cartesian plane, calculate the Manhattan distance to go from point a to point c via point b. Manhattan distance is the sum of the absolute differences of their Cartesian coordinates. Args: a (tuple): Coordinates of point a as (x1, y1). b (tuple): Coordinates of point b as (x2, y2). c (tuple): Coordinates of point c as (x3, y3). Returns: int: The Manhattan distance from point a to point c via point b. ''' ...
NOTE: You can use the below tools for working out and debugging. Click to open them in new tab.
Public Tests ( 3/3 )
Case 1
Input:
texta = (1, 2) b = (3, 4) c = (6, 7) d = manhattan_distance_via_b(a, b, c) is_equal(d, 10)
Case 1
Expected Output:
text10
Case 1
Actual Output:
text10
Case 2
Input:
texta = (0, 0) b = (2, 2) c = (3, 3) d = manhattan_distance_via_b(a, b, c) is_equal(d, 6)
Case 2
Expected Output:
text6
Case 2
Actual Output:
text6
Case 3
Input:
texta = (-1, -1) b = (1, 1) c = (2, 2) d = manhattan_distance_via_b(a, b, c) is_equal(d, 6)
Private Tests ( 3/3 )
Case 1
Input:
texta1 = (5, 5) b1 = (0, 0) c1 = (10, 10) result = manhattan_distance_via_b(a1, b1, c1) is_equal(result, 30)
Case 1
Expected Output:
text30
Case 1
Actual Output:
text30
Case 2
Input:
texta2 = (7, 8) b2 = (2, 3) c2 = (4, 1) result = manhattan_distance_via_b(a2, b2, c2) is_equal(result, 14)
Case 2
Expected Output:
text14
Case 2
Actual Output:
text14
Case 3
Input:
texta3 = (-5, -5) b3 = (0, 0) c3 = (5, 5) result = manhattan_distance_via_b(a3, b3, c3) is_equal(result, 20)
Case 3
Expected Output:
text20
Case 3
Actual Output:
text20
💻 IITM Official Solution
pythondef manhattan_distance_via_b(a: tuple, b: tuple, c: tuple) -> int: ''' Given three points a, b, and c on the Cartesian plane, calculate the Manhattan distance to go from point a to point c via point b. Manhattan distance is the sum of the absolute differences of their Cartesian coordinates. Args: a (tuple): Coordinates of point a as (x1, y1). b (tuple): Coordinates of point b as (x2, y2). c (tuple): Coordinates of point c as (x3, y3). Returns: int: The Manhattan distance from point a to point c via point b. ''' x1,y1,x2,y2,x3,y3 = a+b+c a2b = abs(x1 - x2) + abs(y1 - y2) b2c = abs(x2 - x3) + abs(y2 - y3) return a2b+b2c
💻 My Submitted Code
pythondef manhattan_distance_via_b(a: tuple, b: tuple, c: tuple) -> int: # Manhattan distance = |x1 - x2| + |y1 - y2| # Distance from a to b dist_ab = abs(a[0] - b[0]) + abs(a[1] - b[1]) # Distance from b to c dist_bc = abs(b[0] - c[0]) + abs(b[1] - c[1]) return dist_ab + dist_bc