myCode/ShortestCodeChallenge
-
GetDuplicatesmyCode/ShortestCodeChallenge 2016. 8. 10. 21:12
문제 출처 - https://codefights.com/challenge/x4fLDh2ZYHbaycvFX/main created by Ashish_J_2 문제 ) 무작위의 숫자들이 포함되어 있는 특정한 배열을 input으로 하는 GetDuplicates 함수를 작성한다. 여기서 input 배열에 두 번 이상 들어가는 숫자를 찾아내어 그 숫자가 첫번째로 나온 순서대로 output 배열로 내보낸다. 예시 ) numberList = [1,2,1,1,3,2,4,6,5] GetDuplicates(numberList) = [1,2] 심화 도전 조건 ) 1. 새로운 변수를 만들어선 안된다.2. 기존의 리스트에서 모든 계산을 해내야한다.3. 수행 시간은 linear 해야 한다.
-
pascal_list [reverse_challenge]myCode/ShortestCodeChallenge 2016. 7. 26. 21:08
문득 생각해보면 쉬워보이는 문제지만 코딩을 하면서 '과연 이 방법이 최선일까?' 하는 생각이 들 때가 있다. 이런 경우를 최근들어 자주 경험하고 느껴보면서 ' 멋지고 간드러지게 생각하는 능력' 을 키울 필요성을 느낀다. 다음과 같은 문제를 예로 들어보자. input으로 특정 n 값이 주어지면 파스칼의 삼각형과 비슷한 패턴으로 다음과 같이 벡터를 출력해야한다. n=1 일때 [1] n=2 일때 [1,1] n=5 일때 [1,2,3,2,1] n=6 일땐 [1,2,3,3,2,1] 이런 식으로.. 정말 간단하게 바로 머릿속에 떠오르는 방법은 이거다. n이 짝수, 홀수일 경우를 나눠서 for문을 통해 순차적으로 벡터에 때려박는다. 잘 돌아간다. 누구나 이해할 수 있을 것이다. 하지만 너무 길다. 229자나 된다. 그..
-
Fact (Reverse Challenge)myCode/ShortestCodeChallenge 2016. 7. 4. 20:01
https://codefights.com/challenge/Sm7TY2JehkZXr8zr2/main 보통 답이 너무 커지는 문제는 int의 표시 한계 때문에 모듈러를 이용한 해답을 제시하라고 한다. 그 모듈러의 값은 [ 109 + 7 ] 대표적인 유형이 Factorial 관련 문제다. 이럴땐 a*b의 모듈러는 a의 모듈러 와 b의 모듈러와 같다는 법칙을 이용. 계산 과정마다 해당하는 값으로 나머지를 취하면 된다.
-
EvenNumbersmyCode/ShortestCodeChallenge 2016. 7. 4. 13:19
https://codefights.com/challenge/4HANW3Rbjcs9TZmMM/main Author gamezovladislav2000Number X is called twice even if it is divisible by 2, and number X / 2 is also divisible by 2, yet X / 2 / 2 is not. For example, X = 12 is twice even, since 12 / 2 = 6 - even, and 6 / 2 = 3 is not even.You're given two numbers: N and P. Find the largest number X, such that 1 ≤ X ≤ P and X is divisible by 2 exactl..
-
Reverse_t9myCode/ShortestCodeChallenge 2016. 6. 8. 21:13
Author sudo_su2000Consider that the English alphabet contains 26 characters, while telephones only have ten digits on the keypad. The letters are mapped onto the digits as shown below:When you press a digit, the corresponding letter appears on the screen. If you keep pressing the button without pauses, the letters mapped onto the button change in sequence. Let's assume that no button is pressed ..
-
Cipher_Zeroes [Decimal to Binary]myCode/ShortestCodeChallenge 2016. 6. 4. 14:04
https://codefights.com/challenge/x9TcPgiFRmgN22W44/main Author cynosuredev1000 Nicky and Dev work in a company where each member is given his income in the form of points. On Nicky's birthday, Dev decided to give some of his points as a gift. The number of points Dev is gifting is the total number of visible zeros visible in the string representation of the N points he received this month.Let's ..
-
Turns on RoadmyCode/ShortestCodeChallenge 2016. 5. 17. 20:10
Authoranri 2000There's a wolf who lives in the plane forest, which is located on the Cartesian coordinate system. When going on the hunt, the wolf starts at point (0, 0) and goes spirally as shown in the picture below: The wolf finally found something to eat at point (x, y). Calculate the number of turns he had to make to get to that point.ExampleFor x = 1 and y = 1, the output should be turnsOn..
-
AnagrammyCode/ShortestCodeChallenge 2016. 5. 14. 12:51
How many anagrams (including the initial word) does the given word have? bypokorski2000ExampleFor word = "abc", the output should be Anagrams(word) = 6.For word = "lol", the output should be Anagrams(word) = 3.[input] string wordA word consisting of lowercase English letters. 1 ≤ word.length ≤ 30.[output] integerThe number of anagrams modulo 109 + 7. problem link - https://codefights.com/challen..