Page 1 of 1

Let a string built from the characters ”0”, “1”, and “2”, and 0 be called balanced if it contains an equal number of 1s

Posted: Tue Sep 07, 2021 7:16 am
by answerhappygod
Let a string built from the characters ”0”, “1”, and “2”, and 0
be called balanced if it contains an equal number of 1s and 2s. For
instance, there are 19 balanced sequences of length 4: 0000,0012,
0021, 0102, 0120, 0201, 0210, 1002, 1020, 1122, 1200, 1212, 1221,
2001, 2010, 2100, 2112,2121, and 2211 (note: these are written here
in strictly ascending order, which may or may not be a comfortable
way to find them using a brute force approach).
(a) Count(either by brute force, or by using another technique
if you have a notion of a good approach) the balanced strings of
length 0, 1, 2, and 3. (Note that 0 is a conceptually somewhat
difficult case).
b) Using the data from the example and part (a), identify a
sequence in the Online Encyclopedia of Integer Sequences that seems
to count the balanced strings of length n. The data produced thus
far will not uniquely identify a single OEIS sequence, so
confirming the correct one is a matter either of interpreting the
sequence descriptions or of somehow using the knowledge you already
have to rapidly determine the number of length-5 sequences.