文字列

Pythonで Letter Queue

コード # coding:utf-8 def letter_queue(c): r = [] for i in c: s = i.split() if len(s) == 2 and s[0] == "PUSH": r.extend(s[1]) if len(s) == 1 and r != []: r = r[1:] if r == []: return "" else: return "".join(r) if __name__ == '__main__': le…

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でBrackets

#coding utf-8 import string def checkio(expression): s = expression s = s.encode("utf-8") s = s.translate(string.maketrans("",""),"+-*/0123456789") if s == "": return True t = 0 while t < len(expression): s = s.replace("()","").replace("{}…

PythonでThe Most Wanted Letter

コード3 def checkio(text): s = text.lower() print max("abcdefghijklmnopqrstuvwxyz", key=s.count) コード2 import string def checkio(text): s = text.lower() return max(string.ascii_lowercase, key=s.count) 一言 max()を忘れていた、公式ドキュ…

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でThe Common Words

コード2 def checkio(first,second): f = set(first.split(",")) s = set(second.split(",")) common = f.intersection(s) print ",".join(sorted(common)) コード1 def checkio(first,second): f=first.split(",") s=second.split(",") n=[] for i in f: fo…

PythonでThe End of other

コード def checkio(words_set): words = list(words_set) if len(words) != 1: for i in words: for j in words: if i != j and i.endswith(j): return True return False else: return False 参考にしたサイト python 文字列関数 文字列処理メソッドのまと…