본문 바로가기

전체 글823

Is n divisible by x and y? Description: Create a function that checks if a number n is divisible by two numbers x AND y. All inputs are positive, non-zero digits. Examples: 1) n = 3, x = 1, y = 3 => true because 3 is divisible by 1 and 3 2) n = 12, x = 2, y = 6 => true because 12 is divisible by 2 and 6 3) n = 100, x = 5, y = 3 => false because 100 is not divisible by 3 4) n = 12, x = 7, y = 5 => false because 12 is neith.. 2022. 3. 25.
Find the divisors! Description: Create a function named divisors/Divisors that takes an integer n > 1 and returns an array with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prime' (null in C#) (use Either String a in Haskell and Result in Rust). Example: divisors(12); #should return [2,3,4,6] divisors(25); #shoul.. 2022. 3. 24.
Sum of Digits / Digital Root Description: Digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. The input will be a non-negative integer. Examples 16 --> 1 + 6 = 7 942 --> 9 + 4 + 2 = 15 --> 1 + 5 = 6 132189 --> 1 + 3 + 2 + 1 + 8 + 9 = 24 --> 2 + 4 = 6 493193 --> .. 2022. 3. 23.
Dashatize it Description: Given a variable n, If n is an integer, Return a string with dash'-'marks before and after each odd integer, but do not begin or end the string with a dash mark. If n is negative, then the negative sign should be removed. If n is not an integer, return an empty value. Ex: dashatize(274) -> '2-7-4' dashatize(6815) -> '68-1-5' Solution: 1. If 'n' is not a number, 'None' is returned. 2.. 2022. 3. 22.
HTTP(Hyper Text Transfer Protocol)를 알아보자 HTTP란? HTTP는 서버-클라이언트 모델을 따르면서 리퀘스트, 리스폰스 구조로 웹 상에서 정보를 주고받을 수 있는 프로토콜입니다. TCP/IP 기반으로 작동하며 가장 큰 특징은 connectionless(비연결)와 stateless(무상태)입니다. *리퀘스트 구조 : 스타트 라인(메서드, path, http버전), 헤더, 바디 *리스폰스 구조 : 스테이터스 라인(http버전, status code, status message), 헤더, 바디 '비연결', '무상태'라는 특성은 더 많은 요청을 효율적으로 처리할 수 있도록 돕지만 클라이언트의 상태를 저장하지 않기 때문에 이를 해결하기 위해 쿠키, 세션 등이 사용됩니다. 또한 http는 정보를 text형식으로 주고받으므로 데이터 유출을 막기 위해 암호화를 .. 2022. 3. 21.
Data Reverse Description: A stream of data is received and needs to be reversed. Each segment is 8 bits long, meaning the order of these segments needs to be reversed, for example: 11111111 00000000 00001111 10101010 (byte1) (byte2) (byte3) (byte4) should become: 10101010 00001111 00000000 11111111 (byte4) (byte3) (byte2) (byte1) The total number of bits will always be a multiple of 8. The data is given in a.. 2022. 3. 21.