This can be solved by using combination. Make this a function where X={a1,a2,a3,a4} and Y={0,1,2,...9}. All you have to do is pick 4 numbers from Y. You dont even need to think about the order because the biggest number automatically becomes a1 and the smallest number becomes a4.