본문 바로가기

나는 이렇게 학습한다/Algorithm & SQL405

The Hashtag Generator 문제 설명 The marketing team is spending way too much time typing in hashtags. Let's help them with our own Hashtag Generator! Here's the deal: It must start with a hashtag (#). All words must have their first letter capitalized. If the final result is longer than 140 chars it must return false. If the input or the result is an empty string it must return false. Examples " Hello there thanks for try.. 2022. 2. 22.
Count characters in your string 문제 설명 The main idea is to count all the occurring characters in a string. If you have a string like aba, then the result should be {'a': 2, 'b': 1}. What if the string is empty? Then the result should be empty object literal, {}. 해결 방법 1. 문자열을 요소별로 반복한다. 2. 문자열과 문자열의 수를 딕셔너리 키 값으로 넣는다. def count(string): dict = {} for i in string: try: dict[i] += 1 except KeyError: dict[i] = 1 return dict if로 풀 .. 2022. 2. 21.
Human Readable Time 문제 설명 Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS) HH = hours, padded to 2 digits, range: 00 - 99 MM = minutes, padded to 2 digits, range: 00 - 59 SS = seconds, padded to 2 digits, range: 00 - 59 The maximum time never exceeds 359999 (99:59:59) You can find some examples in the test fixtures. 해결 방법 1. seconds를 .. 2022. 2. 20.
Where my anagrams at? 문제 설명 What is an anagram? Well, two words are anagrams of each other if they both contain the same letters. For example: 'abba' & 'baab' == true 'abba' & 'bbaa' == true 'abba' & 'abbba' == false 'abba' & 'abca' == false Write a function that will find all the anagrams of a word from a list. You will be given two inputs a word and an array with words. You should return an array of all the anagram.. 2022. 2. 19.
Write Number in Expanded Form 문제 설명 You will be given a number and you will need to return it as a string in Expanded Form. For example: expanded_form(12) # Should return '10 + 2' expanded_form(42) # Should return '40 + 2' expanded_form(70304) # Should return '70000 + 300 + 4' NOTE: All numbers will be whole numbers greater than 0. 해결 방법 1. 숫자를 문자열로 바꾼다. 2. 문자열 중에 '0'이 아닌 수를 찾는다. 3. 찾은 수에 현재 남은 자리수 만큼 '0'을 붙인다. 4. 리스트에 담는다. .. 2022. 2. 18.
Split String 문제 설명 Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_'). Examples: solution('abc') # should return ['ab', 'c_'] solution('abcdef') # should return ['ab', 'cd', 'ef'] 해결 방법 1. s의 문자열 수가 만약 홀수라면 뒤에 '_'를 붙인다. 2. 문자열을 두개씩 잘라서.. 2022. 2. 17.