myCode
-
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 ..
-
[C++] 조합(Combination) 구하기myCode/GeneralKnowledge 2016. 6. 6. 19:55
nCk 를 구현해보자. 수학시간에 배웠던 것처럼 평범하게 생각해보면 n!/(n-k)!k! 그러나 이걸 코드로 그대로 구현하는데는 큰 위험이 따른다. n이 조금만 커져도 n!이 int는 물론 long의 한계도 가볍게 뛰어넘는 숫자로 뛰어버린다. 다시한번 수학시간의 기억을 잘 끄집어 내보자. nCk = n-1Ck-1 + n-1Ck 이 식이 기억나는가? 이 식을 토대로 Recursion을 적용한 함수를 구현 해보자. 그러나 이 식도 문제가 있다. Recursion 식이 두개나 들어가면서 수행시간이 2의 제곱 꼴로 비대해진다. 해결책은 바로 Dynamic Programming을 이용하는 것! 참조 - http://karnies.tistory.com/33
-
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..
-
BridgemyCode/ShortestCodeChallenge 2016. 5. 11. 20:51
https://codefights.com/challenge/K4HYozLrbRoLHkt8P Authorpeltorator3000You and your friends like to party but all the party spots are across the bridge from where you guys live. The bridge is quite old and unsafe, so only two people at a time can cross it and they need a lamp to do so at night. Unfortunately, your group only has one lamp. This particular night is very cold, so you want everyone ..
-
FindBoxmyCode/ShortestCodeChallenge 2016. 4. 28. 19:23
Authoranri2000Imagine a box which is full of coins. You want to get it, but you don't want other people to see that you're going towards it, so you're going to go backwards.Assume that the box is located at (0, 0), and you are located at (x, y). You can move only backwards and leftwards to reach the box, and your step is 2 points long (it's just the way your legs work).Calculate how many paths y..
-
DigitBuilder [Subset sum problem]myCode/ShortestCodeChallenge 2016. 4. 25. 19:51
Authorjexis062000Given n number of segments, calculate how many different numbers can be formed, if the segments are used to construct digits following the standard seven-segment display.All segments must be used. The numbers can't have leading zeros.ExampleFor n = 3, the output should be DigitBuilder(n) = 1. The only number you can form is 7.For n = 4, the output should be DigitBuilder(n) = 2. ..