This file contains hidden or 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
#!/usr/bin/python | |
def mergesort(arr,length): | |
if length == 1: | |
return arr | |
else: | |
cut = length/2 | |
left = mergesort(arr[:cut],len(arr[:cut])) | |
right = mergesort(arr[cut:],len(arr[cut:])) | |
return merge(left,right, length) |
This file contains hidden or 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
#!/usr/bin/python | |
def count_inversions(arr, length): | |
if length == 1: | |
return (arr,0) | |
else: | |
left = arr[:length/2] | |
right = arr[length/2:] | |
(a,x) = count_inversions(left, len(left)) | |
(b,y) = count_inversions(right, len(right)) |
This file contains hidden or 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
#!/usr/bin/python | |
import random | |
def quicksort(arr, start, end, pivot_mode='random'): | |
if start < end: | |
split = partition(arr, start, end, pivot_mode) | |
quicksort(arr, start, split-1, pivot_mode) | |
quicksort(arr, split+1, end, pivot_mode) | |
return arr |
This file contains hidden or 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
#!/usr/bin/env python | |
#! -*- coding: utf-8 -*- | |
def build_graph(filename): | |
graph = dict() | |
with open(filename, 'r') as f: | |
for line in f: | |
s,t = line.split() | |
s,t = int(s), int(t) | |
dest_nodes = graph.get(s, set()) |
This file contains hidden or 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 pydub import AudioSegment | |
from google.cloud import speech_v1p1beta1 as speech | |
from google.cloud.speech_v1p1beta1 import enums | |
AUDIO_FILE_PATH_LOCAL = '<PATH TO YOUR FILE WHERE YOU WANT TO REMOVE MUSIC>' | |
AUDIO_FILE_PATH_GCS = '<PATH TO THE SAME FILE IN GCS IF YOU USE THE FIRST SOLUTION>' | |
OUTPUT_FILE_PATH_LOCAL = '<PATH TO SAVE THE OUTPUT FILE>' | |
# Prepare audio files | |
show_without_music = AudioSegment.empty() |