id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > StarWarsSphinxify
prev  |  next  |  chance

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)

public String StarWarsSphinxify(String origStr) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 220

Copyright Nick Parlante 2017 - privacy