Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| # location ~/.tmux.conf | |
| #change prefix from C-b to C-a | |
| unbind C-b | |
| set -g prefix C-a | |
| bind C-a send-prefix | |
| #set mouse off/on | |
| set -g mouse on | |
| #256 colours |
| // Place your settings in this file to overwrite the default settings | |
| { | |
| "editor.cursorBlinking": "solid", | |
| //for terminal to have the correct PATH variable | |
| "terminal.integrated.shellArgs.osx": [ | |
| "-l" | |
| ], | |
| "editor.lineNumbers": "relative", | |
| "editor.renderIndentGuides": true, | |
| "editor.wordWrap": "on", |
| def pairs_range(limit1, limit2): | |
| for i1 in range(limit1): | |
| for i2 in range(limit2): | |
| yield i1, i2 | |
| for x, y in pairs_range(10, 20): | |
| if some_condition(x, y): | |
| break | |
| do_something(x, y) |
| #!/usr/bin/env python | |
| """ | |
| command line program to download gmail inbox messages between specified dates | |
| """ | |
| from __future__ import print_function | |
| import argparse | |
| import pprint | |
| import base64 |
| for x in xrange(100): | |
| print ('fizz'[x % 3 * 4:] + 'buzz'[x % 5 * 4:] or x) |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| def longest_palindrome(s): | |
| for i in range(len(s), 0, -1): | |
| for j in range(len(s)-i+1): | |
| sub = s[j:j+i] | |
| if sub == sub[::-1]: | |
| return i | |
| return 0 |
| def find_outlier(integers): | |
| """return the outlier from integer list""" | |
| parity = [n % 2 for n in integers] | |
| return integers[parity.index(1)] if sum(parity) == 1 else integers[parity.index(0)] |