A ballot number, which we'll label B, is the number of ways of arranging the numbers from 1 through B(B+1)/2 into a triangle, such that each row and column is in any increasing order. The first four ballot numbers are:
a(0) = 1
a(1) = 1
a(2) = 1
a(3) = 2
a(3)
is 2, which means that there are 2 ways of arranging the numbers from 1 to 3(3+1)/2 = 6
in such a triangle:
1 1
2 3 or 2 4
4 5 6 3 5 6
See the OEIS sequence entry for more details.
Your challenge, given a ballot triangle, is to verify its correctness. If it satisfies the conditions of a ballot triangle (rows and columns increasing), you should output how many other ways (excluding the one in the input) there are to arrange the triangle correctly. If the input triangle is incorrectly constructed, you should output nothing.
Trailing newlines are allowed.
Input
A triangle of numbers, which may or may not be a valid ballot triangle. For example:
1
2 3
4 5 6
1
10 5
9 8 2
7 6 4 3
1
3 2
9
2 11
14 3 5
12 8 1 7
15 13 10 4 6
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
Output
If the input is a valid ballot triangle, the remaining number of ways to arrange the same numbers in a valid ballot triangle. If the input is not a valid ballot triangle, nothing. For example, the inputs above produce these outputs (<nothing>
is a placeholder for an actual empty output):
1 # the same as a(3)-1
<nothing>
<nothing>
<nothing>
33591 # the same as a(6)-1
Scoring
This is code-golf: as usual, lowest byte-count wins. Tiebreaker is earliest posted.
1/4 5/2 3 6
valid? \$\endgroup\$