sort6 1127. Two to One Take 2 strings s1 and s2 including only letters from a to z. Return a new sorted string, the longest possible, containing distinct letters - each taken only once - coming from s1 or s2. Examples: a = "xyaabbbccccdefww" b = "xxxxyyyyabklmopq" longest(a, b) -> "abcdefklmopqwxy" a = "abcdefghijklmnopqrstuvwxyz" longest(a, a) -> "abcdefghijklmnopqrstuvwxyz" Solution: String longest(String a, String .. 2022. 11. 27. How Green Is My Valley? Description: Input : an array of integers. Output : this array, but sorted in such a way that there are two wings: the left wing with numbers decreasing, the right wing with numbers increasing. the two wings have the same length. If the length of the array is odd the wings are around the bottom, if the length is even the bottom is considered to be part of the right wing. each integer l of the le.. 2022. 4. 4. Find the middle element Description: As a part of this Kata, you need to create a function that when provided with a triplet, returns the index of the numerical element that lies between the other two elements. The input to the function will be an array of three distinct numbers (Haskell: a tuple). For example: gimme([2, 3, 1]) => 0 2 is the number that fits between 1 and 3 and the index of 2 in the input array is 0. A.. 2022. 3. 9. Is this a triangle? Description: Implement a function that accepts 3 integer values a, b, c. The function should return true if a triangle can be built with the sides of given length and false in any other case. (In this case, all triangles must have surface greater than 0 to be accepted). Solution: 1. Sort a, b, c in ascending order. 2. Compare the last number (largest number) with the sum of the remaining two num.. 2022. 3. 4. Sum of Numbers Description: Given two integers a and b, which can be positive or negative, find the sum of all the integers between and including them and return it. If the two numbers are equal return a or b. Note: a and b are not ordered! Examples (a, b) --> output (explanation) (1, 0) --> 1 (1 + 0 = 1) (1, 2) --> 3 (1 + 2 = 3) (0, 1) --> 1 (0 + 1 = 1) (1, 1) --> 1 (1 since both are same) (-1, 0) --> -1 (-1 .. 2022. 3. 3. 두 개 뽑아서 더하기 문제 설명 정수 배열 numbers가 주어집니다. numbers에서 서로 다른 인덱스에 있는 두 개의 수를 뽑아 더해서 만들 수 있는 모든 수를 배열에 오름차순으로 담아 return 하도록 solution 함수를 완성해주세요. 제한 사항 numbers의 길이는 2 이상 100 이하입니다. numbers의 모든 수는 0 이상 100 이하입니다. 입출력 예 #1 2 = 1 + 1 입니다. (1이 numbers에 두 개 있습니다.) 3 = 2 + 1 입니다. 4 = 1 + 3 입니다. 5 = 1 + 4 = 2 + 3 입니다. 6 = 2 + 4 입니다. 7 = 3 + 4 입니다. 따라서 [2,3,4,5,6,7] 을 return 해야 합니다. 해결 방법 1. numbers를 반복하여 요소를 뽑아낸다. 2. 다음 .. 2022. 2. 9. 이전 1 다음