본문 바로가기

Arr5

On the Canadian Border (SQL for Beginners #2) You are a border guard sitting on the Canadian border. You were given a list of travelers who have arrived at your gate today. You know that American, Mexican, and Canadian citizens don't need visas, so they can just continue their trips. You don't need to check their passports for visas! You only need to check the passports of citizens of all other countries! Select names, and countries of orig.. 2022. 6. 2.
Two to One Description: Take 2 strings s1 and s2 including only letters from ato 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: 1. Concatenate strin.. 2022. 4. 26.
Count the divisors of a number Description: Count the number of divisors of a positive integer n. Random tests go up to n = 500000. Examples (input --> output) 4 --> 3 (1, 2, 4) 5 --> 2 (1, 5) 12 --> 6 (1, 2, 3, 4, 6, 12) 30 --> 8 (1, 2, 3, 5, 6, 10, 15, 30) Solution: 1. Repeat 'n' to generate numbers one after the other. 2. Check whether the generated numbers are divisible by 'n'. 3. Count the number of divisible numbers. fu.. 2022. 3. 12.
Abbreviate a Two Word Name Description: Write a function to convert a name into initials. This kata strictly takes two words with one space in between them. The output should be two capital letters with a dot separating them. It should look like this: Sam Harris => S.H patrick feeney => P.F solution: 1. Change the name to all uppercase letters. 2. Separate strings based on space and put them in an array. 3. Put the first .. 2022. 3. 6.
JavaScript _ 'for문'으로 배열의 합을 구하는 방법 자바스크립트의 경우 배열의 합을 구하는 간단한 내장함수가 없는 것 같습니다. (파이썬 최고..) 라이브러리를 설치하거나 for문 혹은 reduce함수를 사용해야하는데 이번 글에서 for문으로 배열 합을 구하는 함수를 만들어 보겠습니다. 코드부터 볼까요? let a = [1,2,3,4,5]; function sum(a){ let sum = 0; for (let i of a){ sum += i; }; return sum; }; console.log(sum(a)) >>> 15 1. 함수 sum은 배열을 인자로 받습니다. 2. 배열로부터 요소를 뽑아 sum이라는 변수에 반복하여 더합니다. 3. sum 변수를 반환합니다. 이처럼 함수를 미리 작성해두면 Python의 sum() 처럼 배열 합계를 구하는데 사용할 수.. 2022. 3. 5.