about | help | code help+videos | done | prefs |
Write a method that swaps each adjacent character in a string and returns the result. For example, the string "1234567" becomes "2143657". The string "1234" becomes "2143". Notice that the swapping starts at the beginning of the string and continues as long as there is a pair of characters left to swap. If there are an odd number of characters, the last one does not have a "buddy" to swap with, so it just gets placed at the end. Look at the test data for additional examples. nov4_2016_SLHL_swapEveryOther("Lenore") → "eLoner" nov4_2016_SLHL_swapEveryOther("The Raven") → "hT eaRevn" nov4_2016_SLHL_swapEveryOther("books") → "obkos" ...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