본문 바로가기

전체 글

(122)
JS 단어를 입력받아 짝수는 대문자, 홀수는 소문자로 변환 [문제] Write a function toWeirdCase (weirdcase in Ruby) that accepts a string, and returns the same string with all even indexed characters in each word upper cased, and all odd indexed characters in each word lower cased. The indexing just explained is zero based, so the zero-ith index is even, therefore that character should be upper cased. The passed in string will only consist of alphabetical ..
JS 삼각형인지 확인하기 [문제] Implement a method that accepts 3 integer values a, b, c. The method 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). Test.describe("PublicTest", function() { Test.assertEquals(isTriangle(1,2,2), true); Test.assertEquals(isTriangle(7,2,2), false); }); 출처: h..
JS 제곱근, 제곱수 구하기 [문제] You might know some pretty large perfect squares. But what about the NEXT one? Complete the findNextSquare method that finds the next integral perfect square after the one passed as a parameter. Recall that an integral perfect square is an integer n such that sqrt(n) is also an integer. If the parameter is itself not a perfect square, than -1 should be returned. You may assume the parameter..
JS 카드번호 마지막 4글자 빼고 #으로 변환 [문제] Usually when you buy something, you're asked whether your credit card number, phone number or answer to your most secret question is still correct. However, since someone could look over your shoulder, you don't want that shown on your screen. Instead, we mask it. Your task is to write a function maskify, which changes all but the last four characters into '#'. Examples maskify("45563646079..
JS 특정 문자를 공백으로 치환 [문제] Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them. Let's assume that a song consists of some number of words (that don't contain WUB). To make the dubstep remix of this song, Polycarpus inserts a certain number of words "WUB" before the first wo..
JS 입력받은 단어중 가장 짧은 단어의 길이값 구하기 [문제] Simple, given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types. Test.describe("Example tests",_=>{ Test.assertEquals(findShort("bitcoin take over the world maybe who knows perhaps"), 3); Test.assertEquals(findShort("turns out random test cases are easier than writing out basic ones"), 3); }); 출처:..
JS 약수 구하기 [문제] 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); // should re..
코드업 1025 자바 다섯 자리의 정수 1개를 입력받아 각 자리별로 나누어 출력한다. 참고 scanf("%1d%1d%1d%1d%1d", &a, &b, &c, &d, &e); 를 사용하면 1개의 숫자로 각각 구분되어 저장된다. 예시 읽어들인 값을 적당히 바꿔 출력하기 위해서 printf("[%d]", a*10000); 과 같은 방법도 가능하다.