# Problem: A Mindbending Scenario

Want to try solving this problem? You can submit your code online if you log in or register.

The problems in this set are designed to be more accessible to beginning coders. As a learning aid, walkthroughs discussing how to solve the problems in this set are available by clicking on this link. On completion of this problem set, students should know how to use a programming language to read and write files, perform simple arithmetic calculations, and write conditional (if) statements.

## A Mindbending Scenario

Input File: bendin.txt
Output File: bendout.txt
Time Limit: 0.05 seconds

Imagine a universe far different to the one we know. One where where people can walk through walls, where politicians don't lie, where the rules of physics itself are bent on a daily basis. Imagine how strange it would be to land in that universe, having to adjust to entirely new laws of reality, and having to integrate yourself into sentient cultures far beyond human comprehension.

Now, imagine that everything in this universe was suddenly destroyed in a cataclysmic explosion, leaving nothing but two rectangles on an endless plane. These two rectangles have their corners at integer co-ordinates (rational numbers having been destroyed). Your task is to discover the total area of the plane which is covered by these rectangles.

Beware! Some parts of the plane may be covered by both rectangles. If you merely add the individual areas together, you are surely doomed to incorrect answers!

### Input

The input file will consist of two lines. Each line will be of the form x1 y1 x2 y2, describing the bottom-left and top-right corners of one rectangle. You are guaranteed that 0 <= x1 < x2 <= 10,000, and 0 <= y1 < y2 <= 10,000. (That is, each rectangle is at least one unit square in size.)

### Output

Your output file should consist of a single integer: the total area covered by rectangles. (Remember - the rectangles may overlap!)

### Sample Input

```1 1 3 4
2 3 6 7```

`21`

### Explanation

The sample data describes the following two rectangles: The total area covered by the rectangles is 21 unit squares.

### Scoring

The score for each input file will be 100% if the correct answer is written to the output file and 0% otherwise.

Privacy statement
`Page generated: 25 September 2020,  2:35pm AEST`
{"ft_lang_label":"__label__en","ft_lang_prob":0.91932285,"math_prob":0.8166439,"size":2235,"snap":"2020-34-2020-40","text_gpt3_token_len":499,"char_repetition_ratio":0.10219632,"word_repetition_ratio":0.005277045,"special_character_ratio":0.22997762,"punctuation_ratio":0.11290322,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9605366,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-25T04:35:29Z\",\"WARC-Record-ID\":\"<urn:uuid:ea88cea5-1eea-4a13-aca1-3a8f95443537>\",\"Content-Length\":\"5650\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d75d616e-74d7-42b2-a65f-392803bae4af>\",\"WARC-Concurrent-To\":\"<urn:uuid:421c4218-1a87-44b7-9bd3-8838607d47c2>\",\"WARC-IP-Address\":\"137.92.112.100\",\"WARC-Target-URI\":\"http://orac.amt.edu.au/cgi-bin/train/problem.pl?set=simple1&problemid=372\",\"WARC-Payload-Digest\":\"sha1:3GJYR5IBKHEVC7GPNFAWHSIFFLY76GA6\",\"WARC-Block-Digest\":\"sha1:EJLWL34F4DLWQQHJ466VEAJB2ZNHY7ZN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400221980.49_warc_CC-MAIN-20200925021647-20200925051647-00369.warc.gz\"}"}