본문 바로가기

Python345

1101. Fix your code before the garden dies! You have an award-winning garden and every day the plants need exactly 40mm of water. You created a great piece of JavaScript to calculate the amount of water your plants will need when you have taken into consideration the amount of rain water that is forecast for the day. Your jealous neighbour hacked your computer and filled your code with bugs. Your task is to debug the code before your plan.. 2022. 11. 1.
1031. Vowel remover Create a function called shortcut to remove the lowercase vowels (a, e, i, o, u ) in a given string. Examples "hello" --> "hll" "codewars" --> "cdwrs" "goodbye" --> "gdby" "HELLO" --> "HELLO" don't worry about uppercase vowels y is not considered a vowel for this kata Solution: def shortcut(s): return ''.join(i for i in s if i not in "aeiou") def shortcut(s): return s.translate(None, 'aeiou') 2022. 10. 31.
1030. How many stairs will Suzuki climb in 20 years? Suzuki is a monk who climbs a large staircase to the monastery as part of a ritual. Some days he climbs more stairs than others depending on the number of students he must train in the morning. He is curious how many stairs might be climbed over the next 20 years and has spent a year marking down his daily progress. The sum of all the stairs logged in a year will be used for estimating the numbe.. 2022. 10. 30.
1029. Printing Array elements with Comma delimiters nput: Array of elements ["h","o","l","a"] Output: String with comma delimited elements of the array in th same order. "h,o,l,a" solution: def print_array(arr): return ','.join(map(str, arr)) 2022. 10. 29.
1028. Will you make it? You were camping with your friends far away from home, but when it's time to go back, you realize that your fuel is running out and the nearest pump is 50 miles away! You know that on average, your car runs on about 25 miles per gallon. There are 2 gallons left. Considering these factors, write a function that tells you if it is possible to get to the pump or not. Function should return true if .. 2022. 10. 29.
1027. Filling an array (part 1) We want an array, but not just any old array, an array with contents! Write a function that produces an array with the numbers 0 to N-1 in it. For example, the following code will result in an array containing the numbers 0 to 4: arr(5) // => [0,1,2,3,4] Note: The parameter is optional. So you have to give it a default value. Solution: def arr(n: int = 0): return [i for i in range(n)] 2022. 10. 28.