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
1111111111 | |
0000000000 | |
1111111110 | |
0000000001 | |
1111111100 | |
0000000011 | |
1111111101 | |
0000000010 | |
1111111001 | |
0000000110 |
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
# coding: utf-8 | |
import random | |
def quick_sort(inlist): | |
if len(inlist) <= 1: | |
return inlist | |
middle = len(inlist) / 2 | |
pivot = inlist.pop(middle) | |
left, right = [], [] | |
for i in inlist: |
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
# coding: utf-8 | |
# ソーティング練習のコード | |
# マージソート | |
import random | |
import unittest | |
LIMIT = 4 | |
def insert_sort(inlist, begin, end): | |
for i in xrange(begin + 1, end): |
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 <cstdio> | |
#include <iostream> | |
#include <algorithm> | |
#include <map> | |
using namespace std; | |
typedef pair<long,long> Coordinate; | |
int getValue(map<Coordinate, long>_map, long x, long y){ |
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 sys | |
def compare(chunk_key1, chunk_key2): | |
answer = [] | |
for key1, key2 in zip(chunk_key1, chunk_key2): | |
for c1, c2 in zip(key1, key2): | |
if c1 == '?' and c2 == '?': | |
answer.append('a') | |
elif c1 == '?': | |
answer.append(c2) |
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 <cstdio> | |
#include <iostream> | |
#include <vector> | |
#include <map> | |
using namespace std; | |
#define MODULO 1000000007 | |
long factorial(long k) | |
{ |
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> | |
#include <cstdio> | |
#include <vector> | |
#include <list> | |
using namespace std; | |
long getNext(long a, long b, long c, long r){ | |
return (b * a + c) % r; | |
} |
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 sys | |
import re | |
from string import ascii_lowercase | |
ascii_lowercase = ascii_lowercase + " :" | |
def evaluate(string): | |
""" | |
>>> evaluate(":((") | |
False |
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 sys | |
from string import ascii_lowercase | |
def getCharFrequency(string): | |
result = dict() | |
for c in string: | |
lowerC = c.lower() | |
if lowerC in ascii_lowercase: | |
if not result.has_key(lowerC): | |
result[lowerC] = 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
import sys | |
class NicknameSets(object): | |
def __init__(self): | |
self.nickKinds = list() | |
def add(self, a, b): | |
for k in self.nickKinds: | |
if a in k or b in k: | |
k.add(a) |