decorator25 0128. Gauß needs help! (Sums of a lot of numbers). Due to another of his misbehaved, the primary school's teacher of the young Gauß, Herr J.G. Büttner, to keep the bored and unruly young schoolboy Karl Friedrich Gauss busy for a good long time, while he teaching arithmetic to his mates, assigned him the problem of adding up all the whole numbers from 1 through a given number n. Your task is to help the young Carl Friedrich to solve this problem .. 2023. 1. 28. 1112. Sum of Multiples Your Job Find the sum of all multiples of n below m Keep in Mind n and m are natural numbers (positive integers) m is excluded from the multiples Examples sumMul(2, 9) ==> 2 + 4 + 6 + 8 = 20 sumMul(3, 13) ==> 3 + 6 + 9 + 12 = 30 sumMul(4, 123) ==> 4 + 8 + 12 + ... = 1860 sumMul(4, -7) ==> "INVALID" Solution: def invalid_value(func): def wrapper(n, m): return (n 2022. 11. 13. 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. 1013. Area or Perimeter You are given the length and width of a 4-sided polygon. The polygon can either be a rectangle or a square. If it is a square, return its area. If it is a rectangle, return its perimeter. Example(Input1, Input2 --> Output): 6, 10 --> 32 3, 3 --> 9 Note: for the purposes of this kata you will assume that it is a square if its length and width are equal, otherwise it is a rectangle. Solution: def .. 2022. 10. 13. 1008. Drink about Kids drink toddy. Teens drink coke. Young adults drink beer. Adults drink whisky. Make a function that receive age, and return what they drink. Rules: Children under 14 old. Teens under 18 old. Young under 21 old. Adults have 21 or more. Examples: (Input --> Output) 13 --> "drink toddy" 17 --> "drink coke" 18 --> "drink beer" 20 --> "drink beer" 30 --> "drink whisky" Solution: DRINKS = { "Childr.. 2022. 10. 8. 1005. Palindrome Strings Palindrome strings A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. This includes capital letters, punctuation, and word dividers. Implement a function that checks if something is a palindrome. If the input is a number, convert it to string first. Examples(Input ==> Output) "anna" ==> true "walter" ==> false 12321 ==> true 123456 =.. 2022. 10. 5. 이전 1 2 3 4 5 다음