목록분류 전체 보기 (92)
CHIqueen
from collections import Counter def commonCharacterCount(s1, s2): common_letters = Counter(s1) & Counter(s2) return sum(common_letters.values()) 딱히 Counter말고 떠오르는게 없어서 Counter를 썼다. def commonCharacterCount(s1, s2): com = [min(s1.count(i),s2.count(i)) for i in set(s1)] return sum(com) 다른 풀이를 보면 set으로 중복을 없앤 다음 파이썬 str 메서드중 count를 이용해 갯수를세 가장 최소를 구했다.
def allLongestStrings(inputArray): maxd = 0 for i in inputArray: maxd = max(maxd,len(i)) return [i for i in inputArray if len(i) == maxd] 나머지 풀이들을 봤는데 max함수에 key를 len으로만 줘서 반복문 돌릴필요가 없었던것이 신기했다. def allLongestStrings(inputArray): return [i for i in inputArray if len(i) == len(max(inputArray, key=len))]
After becoming famous, the CodeBots decided to move into a new building together. Each of the rooms has a different cost, and some of them are free, but there's a rumour that all the free rooms are haunted! Since the CodeBots are quite superstitious, they refuse to stay in any of the free rooms, or any of the rooms below any of the free rooms. Given matrix, a rectangular matrix of integers, wher..
Below we will define an n-interesting polygon. Your task is to find the area of a polygon for a given n. A 1-interesting polygon is just a square with a side of length 1. An n-interesting polygon is obtained by taking the n - 1-interesting polygon and appending 1-interesting polygons to its rim, side by side. You can see the 1-, 2-, 3- and 4-interesting polygons in the picture below. func shapeA..
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 that. Help him figure out the minimum numb..
Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. Example For inputArray = [3, 6, -2, -5, 7, 3], the output should be adjacentElementsProduct(inputArray) = 21. 7 and 3 produce the largest product. def adjacentElementsProduct(inputArray): return max([inputArray[i] * inputArray[i+1] for i in range(len(inputArray)-1)]) 그냥 다 곱한다음에 ma..
Given the string, check if it is a palindrome. Example For inputString = "aabaa", the output should be checkPalindrome(inputString) = true; For inputString = "abac", the output should be checkPalindrome(inputString) = false; For inputString = "a", the output should be checkPalindrome(inputString) = true. def checkPalindrome(inputString): return inputString==inputString[::-1]
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. Example For year = 1905, the output should be centuryFromYear(year) = 20; For year = 1700, the output should be centuryFromYear(year) = 17. def centuryFromYear(year): return (year + 99) // 100
Write a function that returns the sum of two numbers. Example For param1 = 1 and param2 = 2, the output should be add(param1, param2) = 3. int add(int param1, int param2) { return param1+param2; }
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/yLtrQ/btqCcCPcfhY/XAuyuBRyXZUqLeeAkyFkR1/img.png)
오늘 필기 공부를 위해 기출문제를 다운 받고 인쇄 하려고 봤더니 대략 100개 정도의 한글파일이 나왔다. 인쇄하기 편하기 위해 pdf로 바꾸려고 파일 하나하나 몇번씩 클릭해서 pdf로 바꾸려니 개발 공부해서 어디 엿 바꿔 먹었나 생각이 들어서 바로 hwp를 pdf로 바꾸는 방법을 찾아보다가 https://www.youtube.com/watch?v=5aobDyMFWHo 이 영상을 보게 되었다. 하지만 지금 api가 바뀌어서 그런지 HAction과 HParameterSet이 안보여서 새로 찾다가 방법을 찾아 오랜만에 이 글을 쓰게 되었다. 코드를 먼저 보자 import os import win32com.client as win32 import win32gui BASE_DIR = "C:\\Users\\CHIq..