This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raise ValueError("DEPRECATED/FROZEN - see https://github.com/kastnerkyle/tools for the latest") | |
# License: BSD 3-clause | |
# Authors: Kyle Kastner | |
# Harvest, Cheaptrick, D4C, WORLD routines based on MATLAB code from M. Morise | |
# http://ml.cs.yamanashi.ac.jp/world/english/ | |
# MGC code based on r9y9 (Ryuichi Yamamoto) MelGeneralizedCepstrums.jl | |
# Pieces also adapted from SPTK | |
from __future__ import division | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def phase_vocoder(D, hop_len=None, rate=0.8): | |
"""Phase vocoder. Given an STFT matrix D, speed up by a factor of `rate`. | |
Based on implementation provided by: | |
https://librosa.github.io/librosa/_modules/librosa/core/spectrum.html#phase_vocoder | |
:param D: tf.complex64([num_frames, num_bins]): the STFT tensor | |
:param hop_len: float: the hop length param of the STFT | |
:param rate: float > 0: the speed-up factor | |
:return: D_stretched: tf.complex64([num_frames, num_bins]): the stretched STFT tensor | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import sys | |
def read_data(file): | |
with open(file) as f: | |
raw = map(lambda x: x.split(),f.readlines()) | |
input = list(map(lambda sides: list(map(lambda side: int(side),sides)),raw)) | |
return input | |
def check_tri(input, count = 0): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bitarray import bitarray | |
class BloomFilter: | |
def __init__(self): | |
# use bitarray instead of list to save space | |
self.ba = bitarray(10**8) | |
def _hash_fxn1(self, x): | |
if type(x) == str: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuickSort { | |
// quicksort function in scala | |
def sort(a:Array[Int]) : Array[Int] = { | |
if (a.length < 2) a | |
else { | |
val pivot = a(a.length/2) | |
sort(a.filter(_ < pivot)) ++ a.filter(_ == pivot) ++ sort(a.filter(_ > pivot)) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import timeit | |
# quicksort python | |
def quicksort(a): | |
if len(a) < 2: | |
return a | |
else: | |
pivot = a[int(len(a)/2)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
tic tac toe game in python | |
marko stamenovic | |
june 1 2016 | |
recurse center coding challenge | |
''' | |
#initialize board | |
xsos = [' ',' ',' ',' ',' ',' ',' ',' ',' '] | |
#list of possible moves |