본문 바로가기

map25

0106. Is there a vowel in there? Given an array of numbers, check if any of the numbers are the character codes for lower case vowels (a, e, i, o, u). If they are, change the array value to a string of that vowel. Return the resulting array. Solution: function isVow(a){ for (let index in a) { let vow = String.fromCharCode(a[index]) if (["a", "e", "i", "o", "u"].includes(vow)) { a[index] = vow } } return a } const isVow = a => a.. 2023. 1. 7.
1227. CSV representation of array Create a function that returns the CSV representation of a two-dimensional numeric array. Example: input: [[ 0, 1, 2, 3, 4 ], [ 10,11,12,13,14 ], [ 20,21,22,23,24 ], [ 30,31,32,33,34 ]] output: '0,1,2,3,4\n' +'10,11,12,13,14\n' +'20,21,22,23,24\n' +'30,31,32,33,34' Array's length > 2. Solution: def to_csv_text(array): return '\n'.join(','.join(map(str, i)) for i in array) 2022. 12. 27.
1120. Determine offspring sex based on genes XX and XY chromosomes The male gametes or sperm cells in humans and other mammals are heterogametic and contain one of two types of sex chromosomes. They are either X or Y. The female gametes or eggs however, contain only the X sex chromosome and are homogametic. The sperm cell determines the sex of an individual in this case. If a sperm cell containing an X chromosome fertilizes an egg, the resulting zygote will be .. 2022. 11. 20.
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.
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.
1025. Exclusive "or" (xor) Logical Operator Exclusive "or" (xor) Logical Operator Overview In some scripting languages like PHP, there exists a logical operator (e.g. &&, ||, and, or, etc.) called the "Exclusive Or" (hence the name of this Kata). The exclusive or evaluates two booleans. It then returns true if exactly one of the two expressions are true, false otherwise. For example: false xor false == false // since both are false true x.. 2022. 10. 26.