about | help | code help+videos | done | prefs |
Write a method that uses a string called 'swap', which is always exactly two characters long, to determine which to symbols to swap in the string 'str'. For example, if 'str' is "A man, a plan a canal, Panama." and 'swap' is "an" the resulting string would be "A mna, n plna n cnanl, Pnanmn." because each "a" gets replaced with "n" and each "n" gets replaced with "a". Note that the replacement is case sensitive, which is why the "A" was not replaced. Look at the test data for additional examples. jan30_2020_APP1SLHL_swapLetters("", "az") → "" jan30_2020_APP1SLHL_swapLetters("bannanna, orange, grape, strawberry, plum", "rb") → "rannanna, obange, gbape, stbawrebby, plum" jan30_2020_APP1SLHL_swapLetters("My desk has lots of stuff on it.", "do") → "My oesk has ldts df stuff dn it." ...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