backend

TIL 문제풀이

seul chan 2018. 6. 5. 23:59

18-05-31

# my answer
commit = "0??+0+!!someCommIdhsSt"

def getCommit(commit):
    return ''.join([x for x in list(commit) if x.isalpha()])

# best answer
def getCommit(commit):
    return commit.lstrip('0?+!')

18-06-05

lambda

repeatChar = lambda ch, n: ch * n
def getPoints(answers, p):
    questionPoints = lambda i, ans: i+1 if ans else -p

    res = 0
    for i, ans in enumerate(answers):
        res += questionPoints(i, ans)
    return res
def sortStudents(students):
    students.sort(key= lambda s: s.split()[-1] )
    return students
def isTestSolvable(ids, k):
    digitSum = lambda x: sum(map(int, str(x)))

    sm = 0
    for questionId in ids:
        sm += digitSum(questionId)
    return sm % k == 0


'backend' 카테고리의 다른 글

centos에서 uwsgi 설치 오류 해결 (the gcc failed with exit status 1)  (0) 2019.03.12
serverless 사용해보기  (0) 2019.02.15
Install redis on mac osX  (0) 2018.04.14
Mongodb install in mac OS X  (0) 2018.04.12
nosql: basic usage of OrientDB  (0) 2018.04.10