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
SPC s c remove highlight | |
**** Files manipulations key bindings | |
Files manipulation commands (start with ~f~): | |
| Key Binding | Description | | |
|-------------+----------------------------------------------------------------| | |
| ~SPC f c~ | copy current file to a different location | | |
| ~SPC f C d~ | convert file from unix to dos encoding | | |
| ~SPC f C u~ | convert file from dos to unix encoding | |
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 multiprocessing | |
import pandas as pd | |
import numpy as np | |
def _apply_df(args): | |
df, func, kwargs = args | |
return df.apply(func, **kwargs) | |
def apply_by_multiprocessing(df, func, **kwargs): | |
workers = kwargs.pop('workers') |
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 longestPalindrome(self, s): | |
pt = 0 | |
temp = s | |
while pt < len(temp): | |
temp = temp[:pt]+"#"+temp[pt:] | |
pt += 2 | |
temp = temp + "#" | |
# the up-to-date longest center of palindrome | |
center = 0 | |
# r is for range from the current longest center of palindrome |
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 numpy as np | |
import re, sys | |
from collections import defaultdict | |
def build_board(filename): | |
board = np.zeros((9, 9)) | |
f = open(filename, 'r') | |
for i in range(9): | |
board[i] = [int(k) for k in re.findall(r'\d', f.readline())] | |
return board |
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 numpy as np | |
# Recursion | |
fib = lambda n: fib(n-1)+fib(n-2) if n > 2 else 1 | |
# Memoization | |
def fib_memo(n): | |
register = {0: 0, 1: 1} | |
def helper(count): | |
if count in register: |