6 kyu
Find the integer sequences
285 of 430myjinxin2015
Description:
When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said
Description:
Complete function findSequences
. It accepts a positive integer n
. Your task is to find such integer sequences:
Continuous positive integer and their sum value equals to n
For example, n = 15
valid integer sequences:
[1,2,3,4,5] (1+2+3+4+5==15)
[4,5,6] (4+5+6==15)
[7,8] (7+8==15)
The result should be an array [sequence 1,sequence 2...sequence n]
, sorted by ascending order of the length of sequences; If no result found, return [].
Some examples:
findSequences(3) === [[1,2]]
findSequences(15) === [[7,8],[4,5,6],[1,2,3,4,5]]
findSequences(20) === [[2, 3, 4, 5, 6]]
findSequences(100) === [[18, 19, 20, 21, 22], [9, 10, 11, 12, 13, 14, 15, 16]]
findSequences(1) === []
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Nov 15, 2016 |
Published | Nov 15, 2016 |
Warriors Trained | 1155 |
Total Skips | 40 |
Total Code Submissions | 1341 |
Total Times Completed | 430 |
JavaScript Completions | 285 |
Haskell Completions | 27 |
Python Completions | 129 |
Total Stars | 33 |
% of votes with a positive feedback rating | 97% of 83 |
Total "Very Satisfied" Votes | 78 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |