본문 바로가기

sum56

1204. Odd or Even? Task: Given a list of integers, determine whether the sum of its elements is odd or even. Give your answer as a string matching "odd" or "even". If the input array is empty consider it as: [0] (array with a zero). Examples: Input: [0] Output: "even" Input: [0, 1, 4] Output: "odd" Input: [0, -1, -5] Output: "even" Solution: String oddOrEven(List array) { int result = _sum_array(array); return res.. 2022. 12. 4.
1106. Grasshopper - Messi Goals Messi's Goal Total Use variables to find the sum of the goals Messi scored in 3 competitions Information Messi goal scoring statistics: Competition Goals La Liga 43 Champions League 10 Copa del Rey 5 Task Create these three variables and store the appropriate values using the table above: la_liga_goals champions_league_goals copa_del_rey_goals Create a fourth variable named total_goals that stor.. 2022. 11. 7.
1104. Sum Mixed Array Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers. Return your answer as a number. sum_mix = lambda x: sum(map(int, x)) 2022. 11. 4.
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.
1024. Sum The Strings Create a function that takes 2 integers in form of a string as an input, and outputs the sum (also as a string): Example: (Input1, Input2 -->Output) "4", "5" --> "9" "34", "5" --> "39" "", "" --> "0" "2", "" --> "2" "-5", "3" --> "-2" Notes: If either input is an empty string, consider it as zero. Inputs and the expected output will never exceed the signed 32-bit integer limit (2^31 - 1) Solutio.. 2022. 10. 24.
0930. Count of positives, sum of negatives Given an array of integers. Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers. 0 is neither positive nor negative. If the input is an empty array or is null, return an empty array. Example For input [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15], you should return [10, -65]. Solution: def sorted_arr(func): def w.. 2022. 9. 30.