## The challenge

Create a function that will return a string that combines all of the letters of the three inputed strings in groups. Taking the first letter of all of the inputs and grouping them next to each other. Do this for every letter, see example below!

E.g. Input: “aa”, “bb” , “cc” => Output: “abcabc”

Note: You can expect all of the inputs to be the same length.

## The solution in Java code

Option 1:

 `````` 1 2 3 4 5 6 7 8 9 10 11 `````` ``````public class Solution { public static String tripleTrouble(String one, String two, String three) { StringBuilder sb = new StringBuilder(); for (int i=0; i

Option 2 (using `IntStream`):

 ``````1 2 3 4 5 6 7 8 9 `````` ``````import java.util.stream.Collectors; import java.util.stream.IntStream; public class Solution { public static String tripleTrouble(String one, String two, String three) { return IntStream.range(0, one.length()) .mapToObj(i -> "" + one.charAt(i) + two.charAt(i) + three.charAt(i)) .collect(Collectors.joining()); } } ``````

## Test cases to validate our Java solution

 `````` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 `````` ``````import org.junit.Test; import static org.junit.Assert.assertEquals; import java.util.Random; public class TripleTests { private String alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; private Random randGen = new Random(); @Test public void basicTests() { System.out.println("Hard Coded Tests"); assertEquals("abcabcabc", Solution.tripleTrouble("aaa", "bbb", "ccc")); assertEquals("abcabcabcabcabcabc", Solution.tripleTrouble("aaaaaa","bbbbbb","cccccc")); assertEquals("brrueordlnsl", Solution.tripleTrouble("burn", "reds", "roll")); assertEquals("Supermans", Solution.tripleTrouble("Sea", "urn", "pms")); assertEquals("LexLuthor", Solution.tripleTrouble("LLh","euo","xtr")); } @Test public void randomTests() { System.out.println("Testing 100 random inputs..."); for (int i = 0; i < 100; i++) { int rand = randGen.nextInt(100); String one = randStr(rand); String two = randStr(rand); String three = randStr(rand); String msg = "Should work for:\n" + one + ",\n" + two + ",\n" + three + ".\n"; assertEquals(msg, tripleAns(one, two, three), Solution.tripleTrouble(one, two, three)); } } private String randStr(int n) { String t = ""; for (int i = 0; i < n; i++) { t += "" + alph.charAt(randGen.nextInt(alph.length())); } return t; } private String tripleAns(String a, String b, String c) { String t = ""; for (int i = 0; i < a.length(); i++) { t += a.substring(i, i+1) + b.substring(i, i+1) + c.substring(i, i+1); } return t; } } ``````