Skip to content

Instantly share code, notes, and snippets.

View uncountablecat's full-sized avatar

Yuki K. uncountablecat

  • Mars
View GitHub Profile
@uncountablecat
uncountablecat / elasticTweedie.r
Created November 17, 2018 05:12
tune alpha and lambda of Tweedie model with elastic net
library(caret)
library(HDtweedie)
elasticTweedie = list(library="HDtweedie", type="Regression")
prm = data.frame(parameter=c("alpha", "lambda"),
class=rep("numeric", 2),
label=c("alpha", "lambda_vec"))
elasticTweedieGrid = function(x, y, len=NULL, search="grid") {
class Solution:
def findRepeatedDnaSequences(self, s):
"""
:type s: str
:rtype: List[str]
"""
Map = dict()
for i in range(len(s)-9):
if s[i:i+10] not in Map.keys():
Map[s[i:i+10]] = 1
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isSymmetric(self, root):
"""
def merge(left_array,right_array):
'''
will be used in merge sort
assuming len(left_array) = len(right_array)
'''
result_array = [0]*len(left_array)*2
left_index, right_index = 0, 0
for result_index in range(0,len(result_array)):
if (left_index < len(left_array)-1) and (right_index < len(right_array)-1):