Python345 1211. Maximum Product Task Given an array of integers , Find the maximum product obtained from multiplying 2 adjacent numbers in the array. Notes Array/list size is at least 2. Array/list numbers could be a mixture of positives, negatives also zeroes . Input >> Output Examples adjacentElementsProduct([1, 2, 3]); ==> return 6 Explanation: The maximum product obtained from multiplying 2 * 3 = 6, and they're adjacent nu.. 2022. 12. 11. 1210. Bumps in the Road Your car is old, it breaks easily. The shock absorbers are gone and you think it can handle about 15 more bumps before it dies totally. Unfortunately for you, your drive is very bumpy! Given a string showing either flat road (_) or bumps (n). If you are able to reach home safely by encountering 15 bumps or less, return Woohoo!, otherwise return Car Dead Solution: def bumps(road): return road.cou.. 2022. 12. 11. 1209. Grasshopper - Combine strings Combine strings function Create a function named (combine_names) that accepts two parameters (first and last name). The function should return the full name. Example: combine_names('James', 'Stevens') returns: 'James Stevens' Solution: class Names: @staticmethod def combine(a, b): return " ".join([a, b]) combine_names = Names.combine 2022. 12. 9. 1208. A Strange Trip to the Market You're on your way to the market when you hear beautiful music coming from a nearby street performer. The notes come together like you wouln't believe as the musician puts together patterns of tunes. As you wonder what kind of algorithm you could use to shift octaves by 8 pitches or something silly like that, it dawns on you that you have been watching the musician for some 10 odd minutes. You a.. 2022. 12. 8. pytest _ 테스트 코드에서 현재 시간 바꾸는 방법 현재 시간을 바꾸는 이유 테스트 코드를 작성하다 보면 현재 시간이 특정 시간을 넘겼을 때 정상적으로 코드가 수행되는지 테스트하고 싶을 때가 있다. 예를 들어 만료일자가 있고 오늘 날짜가 만료일자를 지나면 서비스를 중단하는 로직이 있다고 하자. 이를 어떻게 테스트할 수 있을까? 오늘 날짜가 아직 만료일자를 지나지 않았기 때문에 이를 테스트하기 위해서는 오늘 날짜 혹은 만료일자를 mock으로 대체하여 구현해야 한다. 하지만 mock을 직접 구현하는 데에는 코스트가 들기 때문에 아무래도 꺼려지는 방법이다. 만약 당신이 pytest를 사용한다면 pytest-freezegun 라이브러리를 이용해 이 문제를 쉽게 해결할 수 있다. pytest에서 시간 freeze 하는 방법 먼저 pytest-freezegun 라이.. 2022. 11. 17. 1114. Exclamation marks series #6: Remove n exclamation marks in the sentence from left to right Description: Remove n exclamation marks in the sentence from left to right. n is positive integer. Examples remove("Hi!",1) === "Hi" remove("Hi!",100) === "Hi" remove("Hi!!!",1) === "Hi!!" remove("Hi!!!",100) === "Hi" remove("!Hi",1) === "Hi" remove("!Hi!",1) === "Hi!" remove("!Hi!",100) === "Hi" remove("!!!Hi !!hi!!! !hi",1) === "!!Hi !!hi!!! !hi" remove("!!!Hi !!hi!!! !hi",3) === "Hi !!hi!!! !.. 2022. 11. 14. 이전 1 ··· 10 11 12 13 14 15 16 ··· 58 다음