about | help | code help+videos | done | prefs |
Nar Nar Sphinx is a new character who will be appearing in Star Wars Episode 7. He has an unusual way of talking. For really short words or sentences (less than 4 characters) he uses the actual word without changing anything. However, for words, sentences, or symbols of 4 or more characters, he only uses the first two and last two letters, repeating them in the pattern ABBA where A represents the first two letters, and B represents the last two letters. For example, the string "Nar Nar Sphinx" becomes "NanxnxNa". Look at the test data for further examples. Also, don't worry because Nar Nar Sphinx will be thrown into the Great Pit of Carkoon on Tatooine in Episode 8. (IMPORTANT NOTE: The only String methods you are allowed to use in your solution are the .substring and .length methods) StarWarsSphinxify("cat") → "cat" StarWarsSphinxify("when do we eat?") → "wht?t?wh" StarWarsSphinxify("abcd") → "abcdcdab" ...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: 220
Copyright Nick Parlante 2017 - privacy