This file contains 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
import sys | |
import itertools | |
from sys import argv | |
from itertools import combinations | |
from sets import Set | |
def firsthashfun(tuplex): | |
total1 = 0 | |
for i in tuplex: |
This file contains 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
import sys | |
import math | |
users = {} | |
def user_ave(user_a): | |
num = 0 | |
user_sum = 0 | |
for k, v in user_a.iteritems(): |
This file contains 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
import itertools | |
import sys | |
#from itertools import combinations | |
import random | |
#def generate sample | |
if __name__ == '__main__': | |
filename = sys.argv[1] | |
supportNum = int(sys.argv[2]) |
This file contains 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
import networkx as nx | |
import sys | |
from collections import deque | |
import community as cm | |
from collections import defaultdict | |
import matplotlib.pyplot as plt | |
# calculate the betweeness | |
def cal_betweeness(graph): |
This file contains 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
import sys | |
import math | |
def distance(list1,list2): | |
dis = 0 | |
for i in range(0,point_dimension): | |
dis += (list1[i]-list2[i])**2 | |
sqrt_dis = math.sqrt(dis) | |
return sqrt_dis |
This file contains 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
import json | |
import sys | |
import math | |
def convert_item(item): | |
year = str(item['year']).split('-')[0] | |
terminal = item['terminal'] | |
if terminal == 'Terminal 1': | |
terminal = 't1' |
This file contains 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
public class Solution { | |
public int findMaxLength(int[] nums) { | |
for (int i = 0; i < nums.length; i++) { | |
if (nums[i] == 0) nums[i] = -1; | |
} | |
Map<Integer, Integer> map = new HashMap<>(); | |
map.put(0, -1); | |
int sum = 0, max = 0; | |
for(int i = 0; i<nums.length; i++){ | |
sum += nums[i]; |
This file contains 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
/** | |
* Definition for a binary tree node. | |
* public class TreeNode { | |
* int val; | |
* TreeNode left; | |
* TreeNode right; | |
* TreeNode(int x) { val = x; } | |
* } | |
*/ | |