Skip to content

Instantly share code, notes, and snippets.

View Kcrong's full-sized avatar
🇰🇷
Smile

Hyunwoo Kim Kcrong

🇰🇷
Smile
View GitHub Profile
code2idx = {'c4':0, 'd4':1, 'e4':2, 'f4':3, 'g4':4, 'a4':5, 'b4':6,
'c8':7, 'd8':8, 'e8':9, 'f8':10, 'g8':11, 'a8':12, 'b8':13}
idx2code = {0:'c4', 1:'d4', 2:'e4', 3:'f4', 4:'g4', 5:'a4', 6:'b4',
7:'c8', 8:'d8', 9:'e8', 10:'f8', 11:'g8', 12:'a8', 13:'b8'}
# Or use dict comprehension
idx2code = {v: k for k, v in code2idx.items()}
def seq2dataset(seq, window_size):
dataset = []
for i in range(len(seq)-window_size):
subset = seq[i:(i+window_size+1)]
dataset.append([code2idx[item] for item in subset])
return np.array(dataset)
# with for loop
# range() --> starts from 0
def with_for_loop():
for i in range(10):
print('Hit %d times' % (i+1))
print('The tree fell down!!')
def with_while_loop():
hit = 0
@Kcrong
Kcrong / auto_comp.py
Created April 16, 2018 06:16
세 수를 받고, 대소 관계를 >, ==, < 등의 기호로 보여주는 코드
ai = input('num 1: ')
bi = input('num 2: ')
ci = input('num 3: ')
inp = sorted([ai, bi, ci])
operators = ['>', '==', '<']
def exp_c(a, b, op):
return eval("{} {} {}".format(a, op, b))
I will provide git diff, Write me a PR title and PR description in markdown code. And more concise description, the better.
When you response, separate title section and description section so I can copy it easily. title and description must wrapped in the separated markdown code format. DO NOT MIX UP git diff CONTEXTS AMONG MESSAGES.
The PR title must have title itself only. Do not add any other stuff.
The PR description must follow the below format. (Refer three section below)
## What
## Why
## Test