2014-05-01から1ヶ月間の記事一覧

PythonでVerify anagrams

コード def verify_anagrams(first_word, second_word): f = first_word.encode("utf-8") s = second_word.encode("utf-8") f = f.lower().translate(None, ' ') s = s.lower().translate(None, ' ') f = sorted(f) s = sorted(s) if s == f: print "yes" el…

PythonでTransposed Matrix

コード def checkio(data): print zip(*data) 一言 ZIP

PythonでRoman numerals

コード def checkio(data): n4 = [0,1000,2000,3000] r4 = ["","M","MM","MMM"] n3 = [0,100,200,300,400,500,600,700,800,900] r3 = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"] n2 = [0,10,20,30,40,50,60,70,80,90] r2 = ["","X","XX","XXX","X…

PythonでFind Sequence

コード import math def check_hc(matrix,option): if option == 1: matrix = zip(*matrix) s = [x for i in matrix for x in i] for i in range(len(s)-3): if s[i] == s[i+1] == s[i+2] == s[i+3]: return 1 else: return 0 def check_Diagonal(matrix,opt…

PythonでStriped Words

コード2 http://www.checkio.org/mission/striped-words/publications/RRRQ/python-3/first/ からの引用。 すげー綺麗なコードで感動した。 VOWELS = "AEIOUY" CONSONANTS = "BCDFGHJKLMNPQRSTVWXZ" PUNCTUATION = ",.!?" def checkio(text): text = text.u…