I looked into this challenge when I saw a crossword style puzzle where each square has a number, and you have to find which letter corresponds to which number in order to make the words correct. Knowing I'm touching answers already given, I'll try to summarize the problem, and show how it can be solved recursively.
In the x-word case, the smaller array A is a series of numbers, and the large array B contains the letters of the alphabet. The problem is to assign each number to a letter, and to find all possible combinations. Generally we have:
A={1,2,...m} and B={1,2,....n} n>=m
Each possible result can be written as an array C with m elements, where element i carry the value j, for the pair A(i)B(j). The total number of permutations, i.e. C-arrays, is n(n-1).....(n-m+1) or more neatly written: n!/(m+1)!
This number follows from thinking that when the first element of A is paired with any of the elements in B, the second element of A can be paired with any element except the one that was taken by the first one, and so on and on.
We can achieve this with following pseudo-code:
for i= 1 to n
C(1)=B(i)
for j= 1 to n-1
C(2)=B'(j) ' B' is B with element i removed
.........
for x = 1 to n-m
C(m)=B'''(x) 'B is now reduced with (m-1) elements
next x
I use 1-based arrays for intuitivity.
This code would not work for arbitrary length of A, and would be cumbersome to write for large m, so we better make this recursive with a procedure AllPairs, that can call itself:
AllPairs (A,B,C)
if Size(A)>1 ' check no of elements in A
for i=1 to Size(B)
C(Size(C)-Size(A)+1)= B(i)
A'=Remove element 1 from A
B'=Remove element i from B
Call AllPairs(A',B',C) 'recursive call
Next i
else ' only one element in A
for j=1 to Size(B)
C(Size(C)) = B(i) 'looping last element in C through all unused in B
Collect.ADD(C) 'collect C-arrays here for later use
Next j
End AllPairs
Note that C initially is an empty array with same size as A (could as well be a copy of A). C remains the same size, while A and B are succesively reduced, until A contains only one element, and the recursive calling ends. This would do it. Perhaps (with all respect) this is similar to the code Jingie Zheng's answer - (I can't tell). My intent here is to try to give an easy intuitive pseudocode version. This solution can be found implemented in VB here.