Skip to content

Instantly share code, notes, and snippets.


Rohan Pandit rohanp

View GitHub Profile
class Node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
def levelOrderWrong1(root):
curr_level = [root]
levels = []
View diffusion_map.pyx
#cython: wraparound=False, boundscheck=False, cdivision=True, overflowcheck=False
#cython: profile=False, nonecheck=False, cdivision_warnings=True
import numpy as np
cimport numpy as np
from libc.math import sqrt, exp
from sklearn.utils.extmath import fast_dot
from sklearn.metrics.pairwise import pairwise_distances
def diffusion_map(X, n_components=2, metric="euclidean"):
import random
import sys
from time import sleep
from getpass import getpass
def main():
n_games = int(sys.argv[1])
print("You have 100 tanks do distrubute between 5 territories.")
print("Enter the number of tanks to put in each territory.")
print("You may -1 for the territory to auto-select number needed to add to 100.")
import numpy as np
def algorithm(cities):
best_order = []
best_length = float('inf')
for i_start, start in enumerate(cities):
order = [i_start]
length = 0
View gist:a7d2048954377fa9e2bb
cdef DTYPE_t getEpsilon(int xi, DTYPE_t[:,:] RMSD, DTYPE_t[:] epsilonList, DTYPE_t[:] derivativeEpsilonList, int N):
cdef DTYPE_t e,k
cdef int i,j,x,y,neighborsLength
cdef DTYPE_t[:,:] eigenValues=np.zeros((len(derivativeEpsilonList),N), dtype=DTYPE)
cdef DTYPE_t[:,:] neighborsMatrix
cdef DTYPE_t[:] A
for i,e in enumerate(derivativeEpsilonList):
for j in range(N):
View CythonOptimization.pyx
The code was modified so that you dont have to import any libraries or use external files :)
import numpy as np
import sys
#import Bio.PDB
#from scipy import linalg
from time import clock