-
DigitBuilder [Subset sum problem]myCode/ShortestCodeChallenge 2016. 4. 25. 19:51
2000Given
nnumber 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.
Example
- For
n = 3, the output should beDigitBuilder(n) = 1.
The only number you can form is7. - For
n = 4, the output should beDigitBuilder(n) = 2.
It is possible to create numbers4and11.
[input] integer n
The number of segments,
0 ≤ n ≤ 15.[output] integer
The number of different numbers possible to construct.
https://codefights.com/challenge/ox6RH9ZKBKq39SGhJ
성냥개비, 디지털문자, 도형 등 겉포장을 바꿔가면서 자주 나오는 유형의 문제다.
이름하여 Subset sum problem.
여기서는 어떤 숫자 n과 그보다 작은 숫자들이 주어졌을 때 더해서 n이 되는 숫자의 조합들을 찾아내는 방법을 찾아야 할 것 같다.
참조
- http://baboc.tistory.com/270
-http://blog.naver.com/PostView.nhn?blogId=takku04&logNo=150017480080&redirect=Dlog&widgetTypeCall=true
- http://stackoverflow.com/questions/3302814/how-to-find-all-matching-numbers-that-sums-to-n-in-a-given-array
'myCode > ShortestCodeChallenge' 카테고리의 다른 글
Bridge (0) 2016.05.11 FindBox (0) 2016.04.28 Last Two [Fast Exponentiation Algorithm] (0) 2016.04.21 ChessBoardShapes [Flood Fill Algorithm] (0) 2016.04.21 Compress (0) 2016.04.13 - For