How many ternary strings of length 10
contain the pattern 2120?
Ternary strings of length : with
0102212 doesn't contain the pattern 2120
21212021 contains the pattern 2120
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Java solution
Sorry for this ugly solution. I will try to come up with a shorter solution using recursive methods later (I'm in a hurry now). But anyways, I think this is more efficient -