본문 바로가기

Python345

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.
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.
Bit Counting 문제 설명 Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case 해결 방법 1. 들어온 수를 2진수로 바꾼다. 2. 바꾼 수에서 '1'의 개수를 세어 반환한다. def count_bits(n): return bin(n).count('1.. 2022. 2. 16.
Create Phone Number 문제 설명 Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number. Example create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns "(123) 456-7890" The returned format must be correct in order to complete this challenge. Don't forget the space after the closing parentheses! 해결 방법 1. n에 담긴 숫자 요소들을 문자로 바꾼다. .. 2022. 2. 14.