← RoseCode

ROSECODE 201

Balanced triangles

Philippe_57721 · Programming ·

Starting with a sequence of signs + and -, we form a "pascal-like" triangle applying the following rules:
  • the 1st row is the initial sequence
  • each next row is built by combining each 2 consecutive signs from the previous row, with the classical rules ( + ⊗ + ⇒ +, + ⊗ - ⇒ - etc...)
For instance, starting with '-+--', we obtain the following triangle:
- + - -
 - - +
  + -
   -
Such a triangle is said balanced if it contains the same number of + and -.
The following triangle is balanced:
- + - +
 - - -
  + +
   +
Find the number of sequences with 23 signs containing the largest number of + which produce a balanced triangle and give the last one (lexicographic order)

Answer format : count,sequence of + and - without spaces.
PS : count is the number of sequences with that largest number of +.

For 7 signs, the anwser would be : 5,+++-++-

[My timing: 100 sec]