@@ -1453,11 +1453,11 @@ def __init__(self, start, end):
14531453
14541454def classify_line(line):
14551455 match line:
1456- case Line(start=Point(x1 =x1, y1 =y1), end=Point(x2 =x2, y2 =y2)) if x1 == x2 and y1 == y2:
1456+ case Line(start=Point(x =x1, y =y1), end=Point(x =x2, y =y2)) if x1 == x2 and y1 == y2:
14571457 return "point"
1458- case Line(start=Point(x1 =x1, y1 =y1), end=Point(x2 =x2, y2 =y2)) if x1 == x2:
1458+ case Line(start=Point(x =x1, y =y1), end=Point(x =x2, y =y2)) if x1 == x2 and y1 != y2 :
14591459 return "vertical"
1460- case Line(start=Point(x1 =x1, y1 =y1), end=Point(x2 =x2, y2 =y2)) if y1 == y2:
1460+ case Line(start=Point(x =x1, y =y1), end=Point(x =x2, y =y2)) if y1 == y2 and x1 != x2 :
14611461 return "horizontal"
14621462 case Line():
14631463 return "diagonal"
@@ -1475,9 +1475,9 @@ def classify_line(line):
14751475"""
14761476 interpreter .execute (parser .parse (code ))
14771477 assert interpreter .local_env ["result" ] == [
1478- "diagonal " ,
1479- "diagonal " ,
1480- "diagonal " ,
1478+ "point " ,
1479+ "vertical " ,
1480+ "horizontal " ,
14811481 "diagonal" ,
14821482 "not a line" ,
14831483 ]
@@ -1488,9 +1488,9 @@ def analyze_data(data):
14881488 match data:
14891489 case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": x2, "y": y2}] if x == x2 and y == y2:
14901490 return "same point"
1491- case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": x, "y": _}]:
1491+ case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": x, "y": _}] if x == x2 and y != y2 :
14921492 return "same x"
1493- case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": _, "y": y}]:
1493+ case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": _, "y": y}] if y == y2 and x != x2 :
14941494 return "same y"
14951495 case [{"type": "point"}, {"type": "point"}]:
14961496 return "different points"
@@ -1517,9 +1517,9 @@ def analyze_data(data):
15171517 match data:
15181518 case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": x2, "y": y2}] if x == x2 and y == y2:
15191519 return "same point"
1520- case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": x2, "y": _}]:
1520+ case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": x2, "y": _}] if x == x2 and y != y2 :
15211521 return "same x"
1522- case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": _, "y": y2}]:
1522+ case [{"type": "point", "x": x, "y": y}, {"type": "point", "x": _, "y": y2}] if y == y2 and x != x2 :
15231523 return "same y"
15241524 case [{"type": "point"}, {"type": "point"}]:
15251525 return "different points"
@@ -1539,8 +1539,8 @@ def analyze_data(data):
15391539 assert interpreter .local_env ["result" ] == [
15401540 "same point" ,
15411541 "same x" ,
1542- "same x " ,
1543- "same x " ,
1542+ "same y " ,
1543+ "different points " ,
15441544 "invalid data" ,
15451545 ]
15461546
0 commit comments