Although Stephen is working in an IT company, sometimes he needs to do some boring and time consuming jobs. Today, he needs to copy some circuit design from another company. However, due to the policy of that company, bringing soft-copy outside is not allowed. Therefore, he needs to copy the circuit design by hand.
Each circuit can be formulated into a list of rectangle. Each rectangle is denoted by two points - lower left and upper right coordinates. So, all Stephen needs to do is to copy the coordinates by hand. But you know, copying a list of coordinates by hand is super time consuming. Therefore, he is suggested to parse the coordinates to "writable form" using the following method before hand copy.
1. instead of copying lower left (x1,y1) and upper right coordinates (x2,y2), he is suggested to copy the lower left coordinates and the width and height of the rectangle, i.e.,(x,y,w,h)
2. He discovered that most of the rectangles' x / y / w / h in circuit design are the same. So if we write each rectangle in a line and sort the list of 4 numbers in some order, then you will discover that many numbers in line i is the same as the corresponding number in line i-1. In this case, he will not copy the exactly number, he will copy a symbol "*" only.
Here is an example, Originalx1 | y1 | x2 | y2 |
0 | 0 | 70 | 200 |
70 | 130 | 170 | 200 |
170 | 130 | 240 | 330 |
x | y | w | h |
0 | 0 | 70 | 200 |
70 | 130 | 100 | 70 |
170 | 130 | 70 | 200 |
x | y | w | h |
0 | 0 | 70 | 200 |
170 | 130 | * | * |
70 | * | 100 | 70 |
3 0 0 70 200 70 130 170 200 170 130 70 200 3 0 20 1 21 20 20 30 30 20 0 25 5
0 0 70 200 170 130 * * 70 * 170 * 0 20 1 21 20 0 25 5 * 20 30 30Remarks: