2014-04-26から1日間の記事一覧

Pythonで処理時間測定

コード if __name__ == '__main__': time1 = time.clock() #計測したい関数 time2 = time.clock() time = time2*10000 - time1*10000 print time 参考にしたサイト pythonで開始から終了までの処理時間を計測して表示する--listen2the Silence Python - 時間…

PythonでHousePassword

コード3 def checkio(psswd): if (len(psswd) >= 10) and (not psswd.islower()) and (not psswd.isupper()) and (not psswd.isalpha()) and (not psswd.isdigit()): return True #処理時間:0.125s コード2 def checkio(psswd): return ( (len(psswd) >= …

PythonでMedian

コード def checkio(data): if len(data) >= 1000000: return "Long" else: d = len(data) li = sorted(data) if (d + 1) % 2 == 0: print li[(((d + 1) / 2) - 1)] else: n = (d + 1) // 2 print ( li[(n - 1)] + li[n] ) / 2.0 checkio([1,2,3,4,5,6,7,8,9…

PythonでNon Unique Elements

コード def checkio(data): c = [] for i in data: if data.count(i) >= 2: c.append(i) print c 参考にしたサイト python count 要素の確認(in演算子, indexメソッド, countメソッド) - リスト - Python入門