## Rectangle
### Instructions
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
Consider that a point is defined by its coordinates and that a rectangle is defined by the points of the upper left and lower right corners.
- Define two structures named, `point` and `rectangle` .
- The struct `point` has to have two variables, `x` and `y` , type `int` .
- The struct `rectangle` has to have two variables, `upLeft` and `downRight` type `point` .
- The goal is to make a program that:
- Given a slice of points of size `n` returns the smallest rectangle that contains all the points in the vector of points. The name of that function is `defineRectangle` .
- And which calculates and prints the area of that rectangle you define.
### Expected main and function for the program
```go
func defineRectangle(ptr *point, n int) *rectangle {
}
func calArea(ptr *rectangle) int {
}
func main() {
vPoint := []point{}
rectangle := & rectangle{}
n := 7
for i := 0; i < n ; i + + {
val := point{
x: i%2 + 1,
y: i + 2,
}
vPoint = append(vPoint, val)
}
rectangle = defineRectangle(vPoint, n)
fmt.Println("area of the rectangle:", calArea(rectangle))
}
```
### Usage
```console
$ go run .
area of the rectangle: 6
$
```