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

 

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

Write a method that "interlaces" two strings by taking the first character of the first string, then the first character of the second string, then the second character of the first string, then the second character of the second string, and so on... In short, take a character from the first string, then the second string, then move on to the next set of characters. The only problem is that the strings could be different lengths. Once a string is out of characters you just use the remaining characters in the longer string. For example: If you pass in "ABCDE" and "abcdefghi" the method must return "AaBbCcDdEefghi". Look at the test data for further examples. This can be a realtively easy problem if you think carefully about how to solve it. I used 8 lines of code without even trying. I could shorten it to 6 lines without using recursion. I only used one loop. So THINK!


smaugShuffleAdvanced1("", "") → ""
smaugShuffleAdvanced1("Bilbo", "Gandalf") → "BGialnbdoalf"
smaugShuffleAdvanced1("Bigro om", "rne fDo") → "Bringer of Doom"

...Save, Compile, Run (ctrl-enter)

public String smaugShuffleAdvanced1(String first, String second) { }

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: 290

Copyright Nick Parlante 2017 - privacy