1. Compute all 6 pairwise distances: d(p1,p2), d(p1,p3), d(p1,p4), d(p2,p3), d(p2,p4), d(p3,p4) 2. Store distances in a set to find unique values 3. If any distance is 0, return false (duplicate points) 4. If there are exactly 2 unique distances, check counts: - Smaller distance appears 4 times (sides) - Larger distance appears 2 times (diagonals) 5. If both conditions hold, return true 6. Otherwise, return false
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/math-fundamentals/geometry-basics/valid-square-algorithm
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████████████████████████████████████████████████████████████████████████████████