pimaokunです

情報と趣味についてブログを書きます

checkioを少しやってみたやつ

checkio

py.checkio.org


の(自分の)解答を忘れないように残しておきます。

Home編
・House Password

def checkio(data):
    if len(data) < 10:
        return False
    if data.isalpha() == True:
        return False
    if data.isupper() == True:
        return False
    if data.isdigit() == True:
        return False
    if data.isalnum() == True:
        if data.islower() == False:
            return True
    else:
        return False

・The Most Wanted Latter

def checkio(str):
    count = []
    str = str.lower()
    digit = [int(i) for i in range(0,26)]
    alpha_list = [chr(i) for i in range(97,97+26)]
    new = zip(digit,alpha_list)
    judge_dic = dict(new)
    for i in alpha_list:
            i = str.count(i)
            count.append(i)
    jud = count.index(max(count))
    result = judge_dic[jud]
    return result

・Non Unique Elements

def checkio(data):
    mx = max(data)
    mi = min(data)
    for i in range(mi,mx+1):
        if data.count(i) == 1:
            data.remove(i)
    return data

大体のothersの解答がワンライナーだったりするので、技量がつけばやってみたいです。
O'Reilly編までは一応やりました。