Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| /* | |
| * Q: 如何翻转链表中的相邻两个元素? | |
| * Link: http://www.foreach.cn/question/16 | |
| * 比如原链表是: | |
| * a->b->c->d->e->f | |
| * 我们只翻转相邻两个,即1和2翻转,3和4翻转,翻转后如下: | |
| * b->a->d->c->f->e | |
| */ | |
| #include <stdio.h> |
This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.
OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.
| reduce(lambda x,y:10*x+y,map(lambda x:ord(x)-48,a)) |
| import houdini as h | |
| from pygments import highlight | |
| from pygments.lexers import get_lexer_by_name | |
| from pygments.formatters import HtmlFormatter | |
| import misaka as m | |
| from misaka import HtmlRenderer, SmartyPants | |
| # Create a custom renderer | |
| class BleepRenderer(HtmlRenderer, SmartyPants): |
| deb http://run.hit.edu.cn/ubuntu/ natty main universe restricted multiverse | |
| deb-src http://run.hit.edu.cn/ubuntu/ natty universe main multiverse restricted | |
| deb http://run.hit.edu.cn/ubuntu/ natty-security universe main multiverse restricted | |
| deb-src http://run.hit.edu.cn/ubuntu/ natty-security universe main multiverse restricted | |
| deb http://run.hit.edu.cn/ubuntu/ natty-updates universe main multiverse restricted | |
| deb-src http://run.hit.edu.cn/ubuntu/ natty-updates universe main multiverse restricted |
| body { | |
| font-family: Helvetica, arial, sans-serif; | |
| font-size: 14px; | |
| line-height: 1.6; | |
| padding-top: 10px; | |
| padding-bottom: 10px; | |
| background-color: white; | |
| padding: 30px; } | |
| body > *:first-child { |
| a = { | |
| 'a': { | |
| 'x': 1, | |
| 'y': 2 | |
| }, | |
| 'b': 3 | |
| } | |
| b = { | |
| 'a': { |
| import sys | |
| import time | |
| from termcolor import colored | |
| class Progress(object): | |
| def __init__(self): | |
| size = 0 |