myCode/ShortestCodeChallenge
-
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. ..
-
Last Two [Fast Exponentiation Algorithm]myCode/ShortestCodeChallenge 2016. 4. 21. 20:23
https://codefights.com/challenge/ZtjccseoDxaSEkujv AuthorSourMongoose3000Given two integers n and k, find the last two digits of nk.Example: For n = 14 and k = 4, the output should be lastTwo(n, k) = "16"144 = 38416, so the answer is "16".[input] integer n10 ≤ n < 109[input] integer k1 ≤ k < 109[output] stringThe last two digits of nk. n의 k승의 마지막 두자리를 리턴하면 된다.간만에 쉬운 문제다! 라고 쓲쓱 써서 제출하니까 시간 초과..인생..
-
ChessBoardShapes [Flood Fill Algorithm]myCode/ShortestCodeChallenge 2016. 4. 21. 19:26
https://codefights.com/challenge/YPo4BxN4Mu95MksRG Authorsir_ementaler3000A bored student printed out a regular 8 × 8 chessboard and then used a black marker to completely fill in some of the white squares. Knowing which squares he filled in, determine the area (i.e. the number of the chessboard squares) of the largest enclosed black region on the chessboard after his actions.ExampleChessboardSh..
-
CompressmyCode/ShortestCodeChallenge 2016. 4. 13. 11:55
Authorisaf272000You are given a string s. Compress it by replacing its consecutive equal characters with the single one.ExampleFor s = "zz000!!G", the answer should be compress(s) = "z0!G".[input] string sA string that may consists of Latin letters, digits and punctuation marks. 0 ≤ s.length ≤ 4550.[output] stringString s compressed as described above. String 관련 문제는 항상 헷갈린다.원체 활용도도 많고 C++ 표준 라이브..
-
The Euler's totientmyCode/ShortestCodeChallenge 2016. 4. 7. 21:10
Authorvinay_e3000The Euler's totient of a positive integer n is the number of positive integers not greater than n that are relatively prime to n (i.e. their greatest common divisor equals 1). In this challenge, your task is to write a function that computes the Euler's totient of a given number.ExampleeulersTotient(2) = 1 1 is the only number relatively prime to 2.eulersTotient(1) = 1 1 is the ..
-
PolynomialRootmyCode/ShortestCodeChallenge 2016. 4. 6. 20:25
https://codefights.com/challenge/weNspy2jEkhc6aBq9 You are given a list of coefficients of a polynomial and its possible root. The length of the list is equal to the degree of the polynomial - 1, and the constant term of the polynomial is the last element of the list (i.e. polynomial[len(polynomial) - 1]).Find out if the given number is a root of the polynomial.ExampleFor polynomial = [1,-20,150..