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 os | |
import time | |
from amazon.api import AmazonAPI | |
AMAZON_ACCESS_KEY = os.environ['AWSAccessKeyId'] | |
AMAZON_SECRET_KEY = os.environ['AWSSecretKey'] | |
AMAZON_ASSOC_TAG = os.environ['AWSAssocId'] | |
print(AMAZON_ACCESS_KEY[-5:]) | |
print(AMAZON_SECRET_KEY[-5:]) |
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 random import random | |
import time | |
import sys | |
def findCommon_NNN(A,B,C): | |
if 1000<len(A) or 1000<len(B) or 1000<len(C): | |
print("# This may be huge input for this function with O(N^3). Exit.") | |
return [] |
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 <sstream> | |
#include <algorithm> | |
#include <vector> | |
#include <map> | |
#include <math.h> | |
//#include <list> # lower_bound does not work | |
#include <openssl/sha.h> | |
#include <assert.h> |
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 Sorter: | |
def __init__(self,data): | |
self.orig = data.copy() | |
self.data = data | |
def do_qsort(self): | |
print("Original data",self.orig) | |
self.run_qsort(0,len(self.data)-1) | |
print("Sorted data ",self.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
class Sorter: | |
def __init__(self,data): | |
self.data = data | |
def do_msort(self): | |
print("Original data",self.data) | |
self.run_msort(0,len(self.data)-1) | |
print("Sorted data ",self.data) | |
def run_msort(self,i,j): |
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 LCD: | |
def __init__(self,s1,s2): | |
self.s1 = s1 | |
self.s2 = s2 | |
print(s1,s2) | |
def solve(self): | |
a = [ [ 0 for y in range(len(self.s2)+1) ] for x in range(len(self.s1)+1) ] | |
for x in range(len(self.s1)): | |
for y in range(len(self.s2)): |
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 func(a,b=10,*c,**d): | |
print(a,b,c,d) | |
func(1,20,30,40) | |
func([1,20,30,40]) | |
func({'a':1,'b':20,'c':30,'d':40}) | |
func(*[1,20,30,40]) | |
func(**{'a':1,'b':20,'c':30,'d':40}) | |
a = {1:10,2:20} |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <time.h> | |
#include <sys/time.h> | |
int cmp(const void* a, const void* b){ | |
if(*(double*)a<*(double*)b) return -1; | |
if(*(double*)a>*(double*)b) return 1; | |
return 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
unsigned char mask[]={0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; | |
#define tget(i) ( (t[(i)/8]&mask[(i)%8]) ? 1 : 0 ) | |
#define tset(i, b) t[(i)/8]=(b)\ | |
?(mask[(i)%8]|t[(i)/8])\ |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
#include <time.h> | |
#include <sys/time.h> | |
#define STRLEN 10 | |
#define STRLENL 1000 |