# The Third String

Given two strings, output a third string that is not equal to either of the two inputs, but has the same length (in characters) as either of the inputs. There is guaranteed to be at least one valid output.

# Test Cases

Test cases are quoted to show they are strings. Outputs are one of many possible.

input, input -> output

"test", "test" -> "tttt"
"do", "don't" -> "dnut_"
"ye s", "yes" -> "fals"
"yes", "yes" -> "noo"
"maybe", "mayue" -> "false"
"false", "false" -> "truee"
"false", "true" -> "fatr"
"1", "" -> "0"
"", "t" -> "s"
"", "abcabc" -> "testst"
"abcdefghijklmnopqrstuvwxyz", "aaaaaaaaaaaaaaaaaaaaaaaaaa" -> "zbcdefghijklmnopqrstuvwxya"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" -> "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"


## Rules

• You may chose your input domain, but it must be composed of at least printable ASCII, and your output domain must be the same as your input domain.
• The input lengths may be the same or different.
• The output must be valid with probability 1; that is, you may generate random strings until one is valid (and theoretically you might infinite loop), but you can't just output a random string and hope it's valid. Note that this means you output does not need to be deterministic.
• Automatic trailing newlines allowed, but they do not count towards the length of the output.
• Due to questions regarding Memory Errors, it must work within 60 seconds up to input lengths of 6. An answer that works for that and theoretically works for longer strings is OK, but something that Memory Errors on modern computer for input length 4 is not valid.

This is , so shortest answer in bytes wins.

• This seems like another of an interesting new category of questions on this site that are easy for humans and hard for computers. Because computers aren't good at divergent thinking! It reminds me of the Spongebob episode where he's up all night trying to write an essay on what NOT to do at a stoplight. Aug 18 '17 at 22:47
• I understand the output domain can be a subset of the input domain, yes? Aug 18 '17 at 23:21
• Nice question! I like it. Aug 20 '17 at 22:16
• @Quelklef No, that's not different from both inputs. Aug 21 '17 at 2:58
• I suggest "", "1" should be added as a test case, since I just realized my answer fails for this even though it works for all the provided test cases Aug 22 '17 at 23:20

# C# (Mono), 94 bytes

s=>t=>{var r=s!=""?s:t;while(r==s|r==t)r=r.Substring(1).Insert(0,(char)(r[0]+1)+"");return r;}


Try it online!

# Python 3, 67 bytes

lambda a,b:[k for k in"abc"if k not in b[:1]+a[:1]][0]+(a or b)[1:]


Try it online!

Picks the first character of "a", "b", and "c" which neither string begins with - all three characters can't be the first character of one of two strings. The first character of a is then replaced with that character, unless a is empty, in which case the first character in b is replaced instead.

# Pip, 16 bytes

T#iN#*g&iNIg++ii


Try it online!

Increments the number i until i has the same length as one of the inputs and does not equal either of the inputs, and then prints i. Takes about 30 seconds on TIO to output 100000 for length-six input.

# Pip, 16 bytes

YMXgRXX9WyNg--yy


Try it online!

Different approach from my first submission (and much faster):

   g              List of command-line args     ["abc" "9999"]
R             Replace
XX           any character (regex .)
9          with 9                        ["999" "9999"]
MX               Get the max                   9999
Y                 Yank it into y variable
W         Loop while
yNg      y is in the cmdline args:
--y    Decrement y
y  Output y                      9998


# JavaScript (Node.js), 39 bytes

a=>b=>(a[0]&1^b[0]&2^7)+(a||b).slice(1)


Try it online!

Obvious source the 3rd byte

n[]_=[]

• It fails if the string starts with '\1114111'.