about | help | code help+videos | done | prefs |
Given two numbers a and b, build a String that contains every number from a to b, inclusive. Precondition: a < b for all inputs. BUT the output should be in a different sequence than before. Instead of "4567" when a is 4 and b is 7, the output should be "7546" where the first and third numbers are in order on the end of the output, and the second and fourth numbers are in reverse order at the beginning of the output. Another example: if a is 2 and b is 9, the output would be "97532468". HINTS This can be accomplished by using concatenation differently. Concatenation can add to the end of a String, sure, but it can also add to the beginning right? Or, put another way: up to this point you have been thinking of building a String as "add everything to the end," building it from left to right. A String could also be built using concatenation from the inside out, growing in both directions.apcsaLoopsConcatInclusiveTwoWays(4, 7) → "7546" apcsaLoopsConcatInclusiveTwoWays(2, 9) → "97532468" apcsaLoopsConcatInclusiveTwoWays(19, 25) → "24222019212325" ...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: 230
Copyright Nick Parlante 2017 - privacy