# Homework 16 February, 2022 ## Focus on previous days' unsolved problems first. 1. **Rectangle Mania:** You are given an input array of Cartesian coordinates(i.e. (x, y)). Write a program that outputs the number of rectangles formed by these coordinates. A rectangle must have its four corners amongst the input coordinates in order to be counted. We only care about rectangles parallel to the x/y axes, meaning you won't have to worry about 20/30/45 deg rotated rectangles etc. **Input and Output:** 1. ```php [ [0, 0], [0, 1], [1, 1], [1, 0], [2, 1], [2, 0] ] ``` ``` 3 ``` 2. ```php [ [0, 0], [0, 1], [1, 1], [1, 0], [2, 1], [2, 0], [3, 1], [3, 0], [1, 3], [3, 3], [0, -4], [3, -4], [1, -3], [3, -3], [-1, 0], [-10, 0], [-1, -1], [2, -2], [0, -1], [1, -4], [-10, -4] ] ``` ``` 23 ``` 3. ```php [ [0, 0], [0, 1], [1, 0], [2, 1], [1, 3], [3, 3], [0, -4], [3, -5], [1, -3], [3, -2], [-1, 0], [-10, 0], [-1, -1], [2, -2] ] ``` ``` 0 ``` 2. **Generating DOT (gv) Files from graph/tree**: Consult the wiki and documentation for learning about syntax. For a DOT file named `graph_of_dfs.gv`, running the command ```bash dot -Tpng -o image_of_graph.png graph_of_dfs.gv ``` will create a png image file named `image_of_graph.png`. Try to modify your previous codes (related to graph) to also output gv files. Some examples: - Adjacency List Input Array from **Cycle In Graph** problem. - DFS tree from your recursive DFS function in **Cycle In Graph** problem. May also try to color back edge to highlight it. - Family Tree from **Youngest Common Ancestor** problem. May also try to color `descendantOne` and `descendantTwo` to highlight them.