Quote:Original post by MantearQuote:Original post by GoDoG23
You don't need Dn_m; it's just the reasoning behing the formula. When you are in s[0] != s1[0] you know that there are 0 or >=2 differences.
If E0_n-1 is true then the differences are 0 and if E0_n-1 is false the differences are >=2.
I disagree. Having only a boolean return value from the recursive call, it's ambiguous as to whether you have 0, or 2, or 4, or any x*2 number of differences. Show a method in which it is not ambiguous.
What do you want the code?
I give you a formal method to the answer. You are thinking with one subproblem but you could use as many as you want.
isGrey(s0.sub(0, s0.length()-1), ...) is not an ambiguous call. You know that you have at least 1 difference (you are in s0[0] != s1[0]). With that result you could know the real state of isGrey(s0.sub(1, ...).