语言:python 1 # state[0] = 1 to represent a queen 2 # state = (1,3,0,2) 3 # * Q * * 4 # * * * Q 5 # Q * * * 6 # * * Q * 7 def conflict(state, nextX): 8....
分类:
其他好文 时间:
2014-08-05 18:21:09
阅读次数:
221
import threading
def tryfinally(finallyf):
u"returns a decorator that adds try/finally behavior with given no-argument call in the finally"
print "tryfinally"
def decorator(callable):
p...
分类:
编程语言 时间:
2014-08-05 11:17:29
阅读次数:
226
Roman numerals罗马数字的题目, 注意几个关键的数字即可: (100, 400, 500, 900) -> ('C', 'CD', 'D', 'CM'); (10, 40, 50, 90)->('X', 'XL', 'L', 'XC') 1 def checkio(data): 2 .....
分类:
其他好文 时间:
2014-08-05 11:06:19
阅读次数:
232
The Flat Dictionary原来的代码没处理dict为空的情况 1 def flatten(dictionary): 2 #[] is a list 3 #() is a tuple 4 stack = [((), dictionary)] 5 6 res...
分类:
其他好文 时间:
2014-08-05 11:05:59
阅读次数:
204
How to find friends思路简单,编码不易 1 def check_connection(network, first, second): 2 link_dictionary = dict() 3 4 for link in network: 5 dr...
分类:
其他好文 时间:
2014-08-05 11:02:19
阅读次数:
245
Pawn Brotherhood 1 alpha_table = "abcdefgh" 2 3 def safe_pawns(pawns): 4 safe_count = 0 5 6 for spawn in pawns: 7 if spawn[1] == '1'...
分类:
其他好文 时间:
2014-08-05 10:57:49
阅读次数:
278
Xs and Os Referee 1 def checkio(game_result): 2 winner = 'D' 3 4 for row in game_result: 5 if row[0] == row[1] == row[2] and row[0] !...
分类:
其他好文 时间:
2014-08-05 10:44:19
阅读次数:
286
//获取屏幕 宽度、高度#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)//获取系统版本#def...
分类:
其他好文 时间:
2014-08-05 10:43:39
阅读次数:
250
map函数 #?-*-?coding:?cp936?-*-
def?myselfmap(f,*args):
????def?urgymap(f,args):
????????if?args==[]:
????????????return?[]
????????else:
??????????...
分类:
编程语言 时间:
2014-08-04 21:50:28
阅读次数:
239
1.关于定义类的一些奇特之处 今天在Python中定义一个类,很奇怪,不需要事先声明它的成员变量吗?暂时不知,先记录下来:classAccount(object):"一个简单的类"account_type="Basic"def__init__(self,name,balance):"初始化一个新的A...
分类:
编程语言 时间:
2014-08-04 21:25:17
阅读次数:
351