Skip to content

Instantly share code, notes, and snippets.

View dendisuhubdy's full-sized avatar
🚀
at the speed of light

Dendi Suhubdy dendisuhubdy

🚀
at the speed of light
View GitHub Profile
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@dendisuhubdy
dendisuhubdy / rsacrack.py
Created October 20, 2015 02:41
Cracking the RSA cyprtosystem time
import gmpy, time, random, math
def genprime(bits):
p=1
while(gmpy.is_prime(p)==0):
p = random.randrange(math.pow(2,bits-1),math.pow(2,bits))
return p
BITS=20
found=False
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def invertTree(self, root):
"""
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
p = TreeNode(1)
q = TreeNode(1)
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def maxDepth(self, root):
if not root:
@dendisuhubdy
dendisuhubdy / nnls_opt.py
Created December 5, 2015 19:31
Non Negative Least Square algorithm with Log Barrier
"""
A Python implementation of NNLS algorithm
References:
[1] Lawson, C.L. and R.J. Hanson, Solving Least-Squares Problems, Prentice-Hall, Chapter 23, p. 161, 1974.
Contributed by Klaus Schuch ([email protected])
based on MATLAB's lsqnonneg function
"""
sudo -H pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo -H pip install -U
@dendisuhubdy
dendisuhubdy / Gradient descent logistic regression.R
Created February 15, 2016 23:22
Gradient descent logistic regression code file
#'Norm Vec
norm_vec <- function(x){
return (sqrt(sum(x^2)))
}
#' Gradient Step
#'
#' @param gradf handle to function that returns gradient of objective function
#' @param x current parameter estimate
#' @param t step-size
#'Norm Vec
norm_vec <- function(x){
return (sqrt(sum(x^2)))
}
#' Gradient Step
#'
#' @param gradf handle to function that returns gradient of objective function
#' @param x current parameter estimate
#' @param t step-size
@dendisuhubdy
dendisuhubdy / finishedlogit.R
Created February 16, 2016 02:52
logit finished
#'Norm Vec
norm_vec <- function(x){
return (sqrt(sum(x^2)))
}
#' Gradient Step
#'
#' @param gradf handle to function that returns gradient of objective function
#' @param x current parameter estimate
#' @param t step-size