def calculate_perimeter(rectangles):
x_coords = set()
y_coords = set()
for rect in rectangles:
x1, y1, x2, y2 = rect
x_coords.add(x1)
x_coords.add(x2)
y_coords.add(y1)
y_coords.add(y2)
def calc_boundary_perimeter(rectangles):
# find external perimeter of all rectangles
external_perimeter = 0
for rect in rectangles:
x1, y1, x2, y2 = rect
external_perimeter += abs(x2 - x1) + abs(y2 - y1)
# find internal perimeter of overlapping rectangles
internal_perimeter = 0
import sys
def perimeter(rectangles):
perimeter = 0
edges = {}
for rect in rectangles:
x1, y1, x2, y2 = map(int, rect.split())
perimeter += 2 * (x2 - x1 + y2 - y1)
- login server
ssh username@@montana.dataapplab.com -p 49233
mkdir .ssh
- on your computer, open terminal
- check the ~/.ssh exists, if not
mkdir ~/.ssh
- generate ssh keys:
ssh-keygen -t rsa -f ~/.ssh/id_rsa.dal
- edit config
vim .ssh/.config
, type:Host dal
User bhdshaox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct copyStatement{ | |
int used; | |
struct variable *result; | |
struct variable *arg; | |
}copyTable[COPYTABLESTOTAL]; | |
// look up the copyTables | |
struct copyStatement *lookupCopyTables(); | |
// build copyTables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct RWTable{ | |
int flag; // 0: init; 1: read first | |
struct variable *var; | |
int read[RWTOTAL]; | |
int write[RWTOTAL]; | |
struct RWTable *next; | |
}; | |
struct dataDependTable{ | |
int used; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct variable { | |
int used; // 0: not used; 1: used | |
int flag; // 0: integer; 1: variable; 2: temporary; 3: operator | |
char *name; | |
int value; | |
}; | |
struct variable variables[TOTAL]; | |
struct variable temps[TOTAL]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct quad{ | |
int flag; | |
struct variable *operation; | |
struct variable *arg1; | |
struct variable *arg2; | |
struct variable *result; | |
struct quad *next; | |
}quads[TOTAL]; | |
// remove the duplicate assignment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tnode tnodes[TOTAL]; | |
struct expr{ | |
int flag; | |
char *expr; | |
}exprstack[TOTAL]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct temp { | |
char *name; //temporary variable name | |
int flag; //indicate whether the variable is free(0: free; 1: used) | |
} temps[TOTAL]; | |
void inittemps(); | |
struct temp *gettemp(); | |
void freetemp(struct temp *t); |
NewerOlder