파이썬 문제풀이(17)
-
[Python 문제풀이] 6일차
Day_6 Intro. Q11. isLucky Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if the sum of the first half of the digits is equal to the sum of the second half. Given a ticket number n, determine if it's lucky or not. def isLucky(n): n_str = str(n) n_list = list(n_str) sumFront = 0 sumSecond = 0 for i in range(len(n_list)): if i < len(n_list)/2: su..
2020.07.14 -
[Python 문제풀이] 5일차
Day_5 Q10. commonCharacterCount Given two strings, find the number of common characters between them. def commonCharacterCount(s1, s2): s3 = list(s1) s4 = list(s2) save = list() if len(s3) >= len(s4): for i in range(len(s4)): Character = s4[i] try: Idx = s3.index(Character) except: pass else: save.append(s3.pop(Idx)) else: for i in range(len(s3)): Character = s3[i] try: Idx = s4.index(Character)..
2020.07.13 -
[Python 문제풀이] 4일차
Day_4 Q9. allLongestStrings Given an array of strings, return another array containing all of its longest strings. def allLongestStrings(inputArray): maxLen = 0 for word in inputArray: if maxLen < len(word): maxLen = len(word) maxLenList = list() for word in inputArray: if len(word) == maxLen: maxLenList.append(word) return maxLenList 오늘부턴 코드 짜는 과정도 메모해둘 수 있으면 메모해서 올리자 # 문제 파악 # Given an array o..
2020.07.12 -
[Python 문제풀이] 2일차
Day_2 Intro. Q6. Make Array Consecutive 2 Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, each statue having an non-negative integer size. Since he likes to make things perfect, he wants to arrange them from smallest to largest so that each statue will be bigger than the previous one exactly by 1. He may need some additional statues to be able to accomplish ..
2020.07.10 -
[Python 문제풀이] 1일차
Day_1 https://app.codesignal.com/arcade Intro. Q1. add Write a function that returns the sum of two numbers. def add(param1, param2): return param1 + param2 Q2. centuryFromYear Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc. def centuryFromYear(year): if year..
2020.07.09