# Question:Permutations that satisfy conditions.

## Question:Permutations that satisfy conditions.

Maple

Given 2 inputs
m = integer
c = integer

where c ≤ m/2

and variables, a_i, b_i, a, b (all non-negative integers)
Here, m is the digit length of a number where a_i and b_i represent digits in a number writen in base b. a is simply b-1 and is used as another digit.

I am interested in generating specific permutations of a_1 ... a_c  a ... a  b_c ... b_1 where the total number of digits is m and the number of a's in the centre is m-2c.

The permutations I am interested in satisfy the condition. a_i is to the left of b_j for i ≤ j

examples for m=7:
c=1
a1,a,a,a,a,a,b1

c=2
a1,a2,a,a,a,b2,b1
a1,a2,a,a,a,b1,b2
a1,b1,a,a,a,a2,b2
a2,a1,a,a,a,b1,b2
a2,a1,a,a,a,b2,b1

c=3
a1,a2,a3,a,b3,b2,b1
...

c=4
n/a   2c > m

I would like a function L(m,c) that creates all valid permuatations of a_1 .. a_c b_1 .. b_c  (2n terms)

I met up with a lecturer at my university and we came up with this code. Unfortunately it is for mathematica as he doesn't use Maple. I feel there may be a more efficient way than to generate all permutations and then delete some.

thank you in advance for any help.

Ben

﻿