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 -*- | |
from collections import defaultdict | |
import collections.abc | |
import itertools | |
from attr import field, frozen, mutable | |
import fastcore.basics | |
import more_itertools | |
import pydash |
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 functools | |
@functools.partial(lambda wrapper: lambda logger: lambda func: lambda x, y: wrapper(logger, func, x, y)) | |
def exec_with_param_logging(logger, func, x, y): | |
print(f"{logger} calling in, inputs: {x}, {y}.") | |
res = func(x, y) | |
print(f"{logger} calling out, return: {res}.") | |
return res |
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 apiclient | |
import httplib2 | |
import oauth2client.file | |
import operator | |
import re | |
files_api = apiclient.discovery.build('drive', 'v3', http=oauth2client.file.Storage('e:\creds.json').get().authorize(httplib2.Http())).files() | |
items = files_api.list(fields="files(id, name)", q="name = 'audioTest'").execute().get('files', []) | |
if items: | |
parent_id = items[0]['id'] |
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
#define CATCH_CONFIG_MAIN | |
#include "catch.hpp" | |
using namespace std; | |
enum Dir { | |
topDir, | |
leftDir, | |
rightDir | |
}; |
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 <vector> | |
#include <string> | |
using namespace std; | |
vector<bool> GetArrMap(const vector<char> &arr) { | |
vector<bool> arrMap(256, false); | |
for (char curChar : arr) arrMap[curChar] = 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
import apiclient | |
import argparse | |
import httplib2 | |
from oauth2client import tools | |
import oauth2client.client | |
import oauth2client.file | |
import operator | |
import re | |
flow = oauth2client.client.flow_from_clientsecrets('e:\client_secret.json', 'https://www.googleapis.com/auth/drive.metadata') |
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
# you can use print for debugging purposes, e.g. | |
# print "this is a debug message" | |
import itertools | |
def calc_cell(sol, m, n, sums): | |
sol[m][n] = min(itertools.imap( | |
lambda i: max(sol[m - 1][i], calc_sum(sums, i, n)), xrange(m - 1, n))) | |
def calc_sum(sums, i, j): | |
return sums[j] - sums[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
class Replier: | |
def __init__(self, secret): | |
self._diff = None | |
self._secret = secret | |
def answer(self, val): | |
last_diff = self._diff | |
self._diff = abs(val - self._secret) | |
return (-1 if last_diff and self._diff > last_diff else 1) if \ | |
self._diff else 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 <iostream> | |
#include <map> | |
#include <stack> | |
bool IsBalanced(const char delimStr[]) { | |
using std::make_pair; | |
std::map< char, char > delims; | |
const char* curChar = delimStr; | |
std::stack< char > store; |