emacs --daemon to run in the background.
emacsclient.emacs24 <filename/dirname> to open in terminal
NOTE: "M-m and SPC can be used interchangeably".
- Undo -
C-/ - Redo -
C-? - Change case: 1. Camel Case :
M-c2. Upper Case :M-u
- Lower Case :
M-l
| ''' | |
| Sieve is good for pre-generating list of primes, so that you can check quickly if a number is prime or not. | |
| If you're checking if a single number is a prime or not, use the looping method | |
| ''' | |
| import math | |
| def generate_primes_sieve(n): | |
| non_primes = set() |
| # Edit distance problem | |
| class Solution(object): | |
| def minDistance_recursive(self, word1, word2): | |
| """ | |
| Recursive solution | |
| :type word1: str | |
| :type word2: str | |
| :rtype: int |
| import Text.Printf | |
| import Control.Exception | |
| import System.CPUTime | |
| time :: IO t -> IO t | |
| time a = do | |
| start <- getCPUTime | |
| v <- a | |
| end <- getCPUTime | |
| let diff = (fromIntegral (end - start)) / (10^12) |
| class MinHeap: | |
| """Min Heap | |
| """ | |
| def __init__(self): | |
| self.N = 0 | |
| self.vals = [] | |
| self.val2pos = {} | |
| self.pos2key = {} | |
| @property |
| class Trie: | |
| """ | |
| Trie object will try to optimize by keeping unseen suffixes in a single node, | |
| and then unravels those suffixes when the letters in the suffix are encountered | |
| """ | |
| class Node: | |
| """Each trie node""" | |
| def __init__(self): | |
| self.children = {} | |
| self.count = 1 |
| class TrieNode: | |
| def __init__(self): | |
| """Node objects within trie | |
| """ | |
| self.children = {} | |
| self.is_word = False | |
| class Trie: |
| import time | |
| import threading | |
| """ | |
| Threads defined by a class | |
| """ | |
| class CountdownThread(threading.Thread): | |
| def __init__(self,count): | |
| threading.Thread.__init__(self) |
| """ | |
| LRUCache | |
| """ | |
| class LRUCache: | |
| """ | |
| Least Recently Used Cache | |
| Implemented with a dictionary and a linked list | |
| """ | |
| def __init__(self, capacity): |
| def comb[T](l: List[T]): List[List[T]] = l match { | |
| case Nil => List(Nil) | |
| case x::xs => { | |
| val prevResult = comb(xs) | |
| prevResult ++ prevResult.map(y => x::y) | |
| } | |
| } |
emacs --daemon to run in the background.
emacsclient.emacs24 <filename/dirname> to open in terminal
NOTE: "M-m and SPC can be used interchangeably".
C-/C-?M-c
2. Upper Case : M-uM-l