置換

PythonでMorse Clock

コード def checkio(time_string): s = time_string.encode("utf-8").split(":") b = "" for i in s: i = i.zfill(2) li = list(i) if b == "": b = b + format(int(li[0]),"b").zfill(2) + " " else: b = b + format(int(li[0]),"b").zfill(3) + " " b = b …

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

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("{}…