DripSwagon
DripSwagon
CC#
Created by DripSwagon on 3/16/2025 in #help
C# ASP.NET -> Linked List problems
You are probably right, after doing many data checks I believe that all of my data is correct, the problem probably resides within the for loops/ exists, next methods, I appreciate you helping me <3
11 replies
CC#
Created by DripSwagon on 3/16/2025 in #help
C# ASP.NET -> Linked List problems
And do not exists
11 replies
CC#
Created by DripSwagon on 3/16/2025 in #help
C# ASP.NET -> Linked List problems
But the problem now is that all of the triangles are null
11 replies
CC#
Created by DripSwagon on 3/16/2025 in #help
C# ASP.NET -> Linked List problems
By using this
11 replies
CC#
Created by DripSwagon on 3/16/2025 in #help
C# ASP.NET -> Linked List problems
No description
11 replies
CC#
Created by DripSwagon on 3/16/2025 in #help
C# ASP.NET -> Linked List problems
public ListTriangles FindLargestIsoscelesTriangles(ListGroupedCoordinates groupedPoints) { ListTriangles triangles = new ListTriangles(); // New linked list for (groupedPoints.Start(); groupedPoints.Exists(); groupedPoints.Next()) { (string color, CoordinatesList points) = groupedPoints.Get(); if (points.Count() < 3) // Check minimum number of points { triangles.AddToRight(new Triangle(color, null, 0, "not possible")); continue; } double maxPerimeter = 0; Triangle largestTriangle = null; // Iterate over all combinations of 3 points for (points.Start(); points.Exists(); points.Next()) { Coordinates p1 = points.Get(); // Create a new iterator for p2 CoordinatesList pointsForP2 = new CoordinatesList(); for (points.Start(); points.Exists(); points.Next()) { pointsForP2.AddToRight(points.Get()); } pointsForP2 = points; // Copy the list for p2 iteration for (pointsForP2.Start(); pointsForP2.Exists(); pointsForP2.Next()) { Coordinates p2 = pointsForP2.Get(); // Skip if p2 is the same as p1 if (p2 == p1) continue; // Create a new iterator for p3 CoordinatesList pointsForP3 = new CoordinatesList(); for (pointsForP2.Start(); pointsForP2.Exists(); pointsForP2.Next()) { pointsForP3.AddToRight(points.Get()); } pointsForP3 = points; // Copy the list for p3 iteration for (pointsForP3.Start(); pointsForP3.Exists(); pointsForP3.Next()) { Coordinates p3 = pointsForP3.Get(); // Skip if p3 is the same as p1 or p2 if (p3 == p1 || p3 == p2) continue; // Check if the triangle is isosceles if (IsIsosceles(p1, p2, p3)) { double perimeter = GetPerimeter(p1, p2, p3); if (perimeter > maxPerimeter) { maxPerimeter = perimeter; CoordinatesList triangleCoordinates = new CoordinatesList(); triangleCoordinates.AddToRight(p1); triangleCoordinates.AddToRight(p2); triangleCoordinates.AddToRight(p3); largestTriangle = new Triangle(color, triangleCoordinates, perimeter, "available"); } } } } } if (largestTriangle != null) triangles.AddToRight(largestTriangle); else triangles.AddToRight(new Triangle(color, null, 0, "not possible")); } return triangles; }
11 replies