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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
import struct | |
import os | |
import redis | |
import mmh3 | |
import sys | |
import workerpool | |
import logging |
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
import pycassa | |
from multiprocessing import Pool | |
cassa = pycassa.ConnectionPool('test', server_list=['10.1.1.41']) | |
cf = pycassa.ColumnFamily(cassa, 'data') | |
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
class DoubleStackQueue: | |
def __init__(self): | |
self.first_stack = [] | |
self.second_stack = [] | |
def en_queue(self, el = None): |
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
#include <iostream> | |
using namespace std; | |
int select(int array[], int left, int right, int k) { | |
int len = right - left; | |
if (len <= 10) { | |
for (int i = left + 1; i < right; ++i) { | |
for (int j = i; j > left; --j) { | |
if (array[j] < array[j - 1]) { |
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
import sys | |
def quick_sort_1(array, start, end): | |
if start > end: | |
return | |
t = array[start] | |
t_index = start |
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
string_list = ['a', 'b', 'c', 'd', 'e'] | |
used = [0, 0, 0, 0, 0] | |
def dfs_permutation(permu, l): | |
if l == 3: | |
print permu | |
for i in range(len(string_list)): | |
if 0 == used[i]: |
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
import mmh3 | |
class MurmurDict: | |
def __init__(self, capacity = 16, load_factor = 0.75): | |
self.capacity = capacity | |
self.load_factor = load_factor | |
self.table = [] |
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
import sys | |
array = list(sys.argv[1]) | |
def n_pair(array): | |
if len(array) == 0: | |
return True |
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
import sys | |
array = list(sys.argv[1]) | |
l = len(array) | |
dp = [] | |
for i in range(l): | |
dp.append([]) |
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
array = [1, 2, 3, 4 ,5 ,6, 7, 8, 9] | |
odd_pos = 0 | |
for index in range(len(array)): | |
if array[index] & 1 == 1: |
OlderNewer