about | help | code help+videos | done | prefs |
jan30_2020_SLHL_increasingSomehow
Write a method that accepts an array of positive integers. Starting at position zero in the array, return the number of numbers that "increase somehow". Once the first number does not "increase somehow" you are done. So what does "increase somehow" mean? Suppose we have an array {57,140,250,164,3} 140>57 so that was an increase. 250>140 so that was an increase. 164<250 so that would not normally be considered an increase, but this is where the "somehow" comes in! The other way a number can be considered as "increasing somehow" is for more than half of the digits to have increased compared to the corresponding digits in the same position of the original number. So since two out the three digits increased, that is still considered "increasing somehow". But there is no way that the 3 can be considered as increasing, so there are THREE increases. Note that {40,70} is considered to have ONE increase. It is not about how many numbers there are in the increasing sequence, but rather how many increases there are. jan30_2020_SLHL_increasingSomehow([52421, 352, 325, 214, 436, 643]) → 0 jan30_2020_SLHL_increasingSomehow([]) → 0 jan30_2020_SLHL_increasingSomehow([5]) → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy