Skip to content

Instantly share code, notes, and snippets.

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)
  1. login server
  • ssh username@@montana.dataapplab.com -p 49233
  • mkdir .ssh
  1. 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

struct copyStatement{
int used;
struct variable *result;
struct variable *arg;
}copyTable[COPYTABLESTOTAL];
// look up the copyTables
struct copyStatement *lookupCopyTables();
// build copyTables
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;
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];
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
tnode tnodes[TOTAL];
struct expr{
int flag;
char *expr;
}exprstack[TOTAL];
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);