728x90
반응형

Computer science/알고리즘

[자바스크립트로 구현한 알고리즘] Disemvowel Trolls

Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat. Your task is to write a function that takes a string and return a new string with all vowels removed. For example, the string "This website is for losers LOL!" would become "Ths wbst s fr lsrs LL!". 모음만 제거하는 예제다. 정규표현식 /[aeiou]/ gi..

2016.09.17 게시됨

Computer science/알고리즘

[자바스크립트로 구현한 알고리즘] Beginner Series #3 Sum of Numbers

Given two integers, which can be positive and negative, find the sum of all the numbers between including them too and return it. If both numbers are equal return a or b. Note! a and b are not ordered! Example: GetSum(1, 0) == 1 // 1 + 0 = 1 GetSum(1, 2) == 3 // 1 + 2 = 3 GetSum(0, 1) == 1 // 0 + 1 = 1 GetSum(1, 1) == 1 // 1 Since both are same GetSum(-1, 0) == -1 // -1 + 0 = -1 GetSum(-1, 2) ==..

2016.09.17 게시됨

Computer science/알고리즘

[자바스크립트로 구현한 알고리즘] Count by X

Create a function with two arguments that will return a list of length (n) with multiples of (x). Assume both the given number and the number of times to count will be positive numbers greater than 0.Return the results as an array (or list in Python, Haskell or Elixir). Examples: countBy(1,10) === [1,2,3,4,5,6,7,8,9,10] countBy(2,5) === [2,4,6,8,10] 이런 방법으로 첫 코딩을 작성했다. 좀 더 보기 좋은 코드로는 이렇게 작성도 가능하다.

2016.09.12 게시됨

728x90
반응형