Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
Ctrl+C | copy current line (if no selection) |
Ctrl+X | cut current line (if no selection) |
Ctrl+⇧+K | delete line |
Ctrl+↩ | insert line after |
{ | |
"auto_complete_commit_on_tab": true, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/User/Monokai Soda.tmTheme", | |
"default_line_ending": "unix", | |
"detect_slow_plugins": false, | |
"draw_minimap_border": true, | |
"draw_white_space": "all", | |
"fade_fold_buttons": false, | |
"font_face": "Ubuntu Mono", |
Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
Ctrl+C | copy current line (if no selection) |
Ctrl+X | cut current line (if no selection) |
Ctrl+⇧+K | delete line |
Ctrl+↩ | insert line after |
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
算法导论, “哨兵牌”版本 | |
""" | |
INF = float("inf") | |
def merge_sort(A, p, r): | |
if p < r: |
from random import randrange | |
seq = [randrange(10**10) for i in range(100)] | |
seq.sort() | |
dd = float("inf") | |
for i in range(len(seq)-1): | |
x, y = seq[i], seq[i+1] | |
if x == y: continue | |
d = abs(x-y) | |
if d < dd: | |
xx, yy, dd = x, y, d |
#-*-coding:utf-8-*- | |
def counting_sort(A, k): | |
B, C = [0] * len(A), [0] * (k + 1) # 包括0和k,长度k+1 | |
for a in A: | |
C[a] += 1 | |
for i in range(1, k + 1): # 1 to k | |
C[i] += C[i-1] | |
for j in range(len(A) - 1, -1, -1): | |
# 这里要注意索引从0开始的,所以要-1 | |
B[C[A[j]] - 1] = A[j] |
s = 'abcdefgh' | |
r = s[::-1] | |
print(r) #a : hgfedcba |
class Node: | |
p = None | |
left = None | |
right = None | |
def __init__(self, key, val): | |
self.key = key | |
self.val = val | |
class Tree: |
def gcd(i, j): | |
while i != 0: | |
if j >= i: | |
j -= i | |
else: | |
i, j = j, i | |
return j | |
i = int(raw_input("i:")) | |
j = int(raw_input("j:")) |
import timeit | |
from functools import partial | |
t1 = timeit.Timer(partial([func, *args])).timeit(1) | |
print(t1) |
''' | |
From Python Algorithms - Mastering Basic Algorithms in the Python Language Book | |
''' | |
def partition(seq): | |
pi, seq = seq[0], seq[1:] # Pick and remove the pivot | |
lo = [x for x in seq if x <= pi] # All the small elements | |
hi = [x for x in seq if x > pi] # All the large ones | |
return lo, pi, hi # pi is "in the right place" | |