-
[JS/입력값검증] 숫자 3자리마다 ,(콤마)찍기 / 숫자와 콤마를 제외한 문자 입력 제한 / 0으로 시작 못하게 제한 / keyup이벤트Frontend 2019. 4. 19. 23:10
오늘은 input박스에 숫자를 입력했을 때 여러가지 이벤트 주는 것을 구현해보려고 한다. 키보드를 입력하는 것과 동시에 이벤트가 발생해야하므로 keyup이벤트를 사용할 예정이다. 1. 숫자 3자리마다 ,(콤마)찍기 2. 숫자와 콤마를 제외한 나머지 문자를 입력할 수 없도록 막기 3. 0으로 시작하지 못하게 제한하기 먼저 숫자 3자리마다 콤마를 찍기 위해 아래와 같은 함수를 만들어보았다. function insertComma(num) { if(num.length
-
[알고리즘/자바스크립트] 트리보나치, 피보나치 수열 "재귀함수"로 구하기 (Fibonacci, Tribonacci Sequence)Algorithm 2019. 4. 15. 00:28
[알고리즘/자바스크립트] 트리보나치 수열 구하기 (Tribonacci Sequence) -해당 문제는 codewars사이트의 level6 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Well met with Fibonacci bigger brother, AKA Tribonacci. As the name may already reveal, it works basicall.. im-developer.tistory.com 2개월 전에 풀었던 알고리즘 문제를 "재귀함수"를 이용해서 풀어보았다. 지난번에는 위 링크를 보면 알겠지만 function tribonacci (signature, n) { if(n
-
[알고리즘/자바스크립트] 배열에서 반대 방향 제거하기 (Directions Reduction)Algorithm 2019. 4. 9. 22:44
-해당 문제는 codewars사이트의 level5 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Once upon a time, on a way through the old wild west,… … a man was given directions to go from one point to another. The directions were "NORTH", "SOUTH", "WEST", "EAST". Clearly "NORTH" and "SOUTH" are opposite, "WEST" and "EAST" too. Going to one direction and coming back the opposite direction is a needless effort. Since this is..
-
[알고리즘/자바스크립트] 초를 시:분:초 형태로 변환하기 (Human Readable Time)Algorithm 2019. 4. 5. 22:38
-해당 문제는 codewars사이트의 level5 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS) HH = hours, padded to 2 digits, range: 00 - 99 MM = minutes, padded to 2 digits, range: 00 - 59 SS = seconds, padded to 2 digits, range: 00 - 59 The maximum time never exceeds 359999 (99:59:59) You can ..
-
[알고리즘/자바스크립트] 대문자 기준으로 글자 변환하기 (Convert PascalCase string into snake_case)Algorithm 2019. 4. 2. 00:21
-해당 문제는 codewars사이트의 level5 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Complete the function/method so that it takes CamelCase string and returns the string in snake_case notation. Lowercase characters can be numbers. If method gets number, it should return string. // returns test_controller toUnderscore('TestController'); // returns movies_and_books toUnderscore('MoviesAndBooks'); // returns app7_tes..
-
[알고리즘/자바스크립트] 덧셈 알고리즘 (Adding Big Numbers)Algorithm 2019. 3. 17. 17:11
-해당 문제는 codewars사이트의 level4 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] We need to sum big numbers and we require your help. Write a function that returns the sum of two numbers. The input numbers are strings and the function must return a string. - Exampleadd("123", "321"); -> "444"add("11", "99"); -> "110" - NotesThe input numbers are big.The input is a string of only digitsThe numbers are positives ..
-
[알고리즘/자바스크립트] 배열의 값으로 수량 체크하기 (Help the bookseller!)Algorithm 2019. 3. 3. 21:31
-해당 문제는 codewars사이트의 level6 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] A bookseller has lots of books classified in 26 categories labeled A, B, ... Z. Each book has a code c of 3, 4, 5 or more capitals letters. The 1st letter of a code is the capital letter of the book category. In the bookseller's stocklist each code c is followed by a space and by a positive integer n (int n >= 0) which indicates th..
-
[알고리즘/자바스크립트]스도쿠 판별 알고리즘 (Did I Finish my Sudoku?)Algorithm 2019. 3. 2. 17:48
-해당 문제는 codewars사이트의 level5 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Write a function done_or_not/DoneOrNot passing a board (list[list_lines]) as parameter. If the board is valid return 'Finished!', otherwise return 'Try again!' Sudoku rules:Complete the Sudoku puzzle so that each and every row, column, and region contains the numbers one through nine only once. Rows: There are 9 rows in a tradition..
-
[알고리즘/자바스크립트] 배열에 요소 추가하고 합치기 (Create Phone Number)Algorithm 2019. 2. 24. 21:05
-해당 문제는 codewars사이트의 level6 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number. Example:createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890" The returned format must be correct in order to complete this challenge. Don't forget the space after..
-
[알고리즘/자바스크립트] 두 객체를 비교하여 케이크 만들 수 있는 최대 횟수 구하기 (Pete, the baker)Algorithm 2019. 2. 24. 20:40
-해당 문제는 codewars사이트의 level5 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Pete likes to bake some cakes. He has some recipes and ingredients. Unfortunately he is not good in maths. Can you help him to find out, how many cakes he could bake considering his recipes? Write a function cakes(), which takes the recipe (object) and the available ingredients (also an object) and returns the maximum number of cak..