Skip to content

Instantly share code, notes, and snippets.

View haje01's full-sized avatar

Kim Jeong Ju haje01

View GitHub Profile
@haje01
haje01 / festival.py
Created November 24, 2014 11:57
손고리즘 - Festival
def calc_mavg(prc, ft):
mavg = 100
n = len(prc)
fs = 0
for start in xrange(0, n - ft + 1):
cur = start + ft
fs = sum(prc[start:cur]) if fs == 0 else fs - prc[start - 1] + prc[cur - 1]
avg = fs / float(cur - start)
if avg < mavg:
mavg = avg
@haje01
haje01 / festival2.py
Created November 24, 2014 12:14
손고리즘 - Festival2
def calc_mavg(prc, ft):
t = 0
aprc = []
for p in prc:
t += p
aprc.append(t)
n = len(prc)
ma = 100 * n
for s in xrange(0, n - ft + 1):
i = s - 1
def gen_data():
a = 1983
po = pow(2, 32)
while True:
yield a % 10000 + 1
a = (a * 214013 + 2531011) % po
def do_case(k, n):
head = gen_data().next
def do_case(n, ok):
a = range(2, n+1)
la = len(a)
k = 0
while la > 2:
k = (k + ok - 1) % la
a.pop(k)
la -= 1
return a
@haje01
haje01 / dynamicprog.ipynb
Last active August 29, 2015 14:14
동적계획법 보강 코드
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@haje01
haje01 / pi.py
Created February 2, 2015 11:50
원주율 외우기
def sfn1(na, o):
a, b, c = na[o-2], na[o-1], na[o]
if a == b and b == c:
return 1
df = b - a
if df == c - b:
return 2 if abs(df) == 1 else 5
elif a == c:
return 4
return 10
cache = None
def memoize(fn):
global cache
def helper(w, ts, i):
if cache[w][i] == -1:
cache[w][i] = fn(w, ts, i)
return cache[w][i]
@haje01
haje01 / NLTK ch7-ex.ipynb
Created March 26, 2015 14:27
NLTK Book Ch7-Ex
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@haje01
haje01 / .vimrc
Created May 6, 2015 01:44
.vimrc
" My .vimrc
syntax on
set ic
set tabstop=4
set shiftwidth=4
set autoindent
set hlsearch
set smartindent
set backspace=2
@haje01
haje01 / caffe_test.diff
Created July 1, 2015 03:32
Caffe 파이썬 테스트를 위해 수정할 것
diff --git a/python/caffe/io.py b/python/caffe/io.py
index fc96266..02b2ffb 100644
--- a/python/caffe/io.py
+++ b/python/caffe/io.py
@@ -251,9 +251,13 @@ class Transformer:
ms = (1,) + ms
if len(ms) != 3:
raise ValueError('Mean shape invalid')
- if ms != self.inputs[in_][1:]:
- raise ValueError('Mean shape incompatible with input shape.')