How to find the N-th 3 word sequence within the following constraints I have a list of words. Let's say that I have an algorithm(explained below) to generate the permutations in a specific order. I want to be able to find the N-th permutation easily. 
I want to make sure that the algorithm I use will create all permutations out of the already seen words before going on to the next word.
As an example let's say that A,B,C,D,E and F are the words that I have, in that order. I want to make sure that the algorithm generates all possible permutations out of A, B, C before moving to D. Then generate all permutations out of A, B, C, D before moving to E. I am open to reusing the same word within the same 3 word group or not.
And I want to be able to find the N-th permutation given from the above algorithm without having to generate all the permutations till the N-th one.
What is an algorithm that fits above criteria and how can I get the N-th permutation?
PS:- I have thought about the problem but all I can come up with up to now is something like the following. I will explain it here because you would want to know what I have tried.
Have an index, i and keep incrementing it. Find the binary representation of the number. If the number has three '1' digits, the words at the '1' bit indexes will form a 3 word group. But this method requires me to generate all permutations.
Pardon my wording if I have not used the correct wording. I am not a mathematician, but felt that this question was more suited here.
 A: Below is a Python 3 program that generates the permutations in this order. I generate the permutations of A,B,C, then I go through all of the permutations of 3-word groups of A,B,C,D, then I do the same for A,B,C,D,E, then I do the same for A,B,C,D,E,F. I do not repeat words in a permutation.
The way I do this is by using your idea of using a binary number with 3 bits, but then using shortcuts to get right to the binary number we want without generating all of them.
Now, here is the algorithm:
import math
# We want to find the Nth permutation
N = 24
# This is the number of words in a group
num_words_in_group = 3
# These are our six words:
words = ["A", "B", "C", "D", "E", "F"]
# This is the number of words in all:
num_words_in_all = len(words)

'''
Now, we know that each set of 3 words has num_words_in_group!=6 permutations,
so the ((N-1)//6+1)th set of 3 words must have the Nth permutation:
This is because we subtract N by 1 to go from 1-indexing to 0-indexing,
then divide by 6 to account for that each signifier has 6 permutations,
then add 1 to go from 0-indexing to 1-indexing.

Now, we want to do ABC first, which can be represented by 000111
because we are doing the first three letters.
Then, we can go to 001011 (ABD), then 001101 (ACD), then 001110 (BCD),
and so on, until we get to the ((N-1)//6+1)th 6-digit binary number with 3 ones.

Now, we want to get through all of the numbers with only 3 bits,
which has (3 choose 3) combinations. This is A,B,C.
We then want to get through all of the numbers with only 4 bits,
which has (4 choose 3) combinations. This is A,B,C,D.
We then want to get through all of the numbers with only 5 bits,
which has (5 choose 3) combinations. This is A,B,C,D,E.

Thus, if we only allow ourselves to use the last l digits
with k ones, it takes (l choose k) combinations.

Using this logic, we will find the first bit with a 1
by finding the biggest l possible such that
(l choose k) < (N-1)//6+1
Then, we will subtract (N-1)//6+1 by (l choose k)
and then set the (l+1)th bit in our binary number with a 1
and then we will have l bits with k-1 bits that need to be 1s,
at which point the process restarts.
'''

def find_signifier(num_set_wanted, num_ones, max_bits):
    # This is the binary number we will return:
    signifier = 0
    '''
    If num_set_wanted=1, then we want all of the ones to be altogether,
    like in 000111.
    However, this is an exception to the algorithm below,
    so we're going to do this manually.
    '''
    if num_set_wanted == 1: return (1 << num_ones)-1

    # This is l choose k, where k is num_ones:
    l_choose_k = 1
    '''
    The following is the l we talked about above:
    We start with num_ones because
    it is the minimum number of bits because we have num_ones 1s,
    so each 1 will each take up a bit.
    We also end at max_bits since it is the maxmimum number of bits.
    '''
    for l in range(num_ones, max_bits):
        # This is l+1 choose k:
        l_plus_1_choose_k = l_choose_k*(l+1)//(l-(num_ones-1))
        # If num_set_wanted is betwen l choose k and l+1 choose k,
        # then we have that we only need l bits.
        if num_set_wanted > l_choose_k and num_set_wanted <= l_plus_1_choose_k:
            # Now, mark the (l+1)th bit in signifier:
            signifier += 1 << l
            # Then, if we still have 1s left,
            # decrement num_ones,
            # set max_bits to l, and
            # decrease num_set_wanted by l_choose_k:
            if num_ones > 0:
                signifier += find_signifier( \
                    num_set_wanted-l_choose_k, num_ones-1, l \
                )
                # Once we're done, break from the loop
                break
        # Otherwise, if this isn't it, update l_choose_k:
        else: l_choose_k = l_plus_1_choose_k

    # Finally, return signifier
    return signifier

# This is the number of permutation each group of words has:
# In this case, it is 3!=6.
num_permutations = math.factorial(num_words_in_group)
# Get the bits that will tell us which words to include:
current_signifier = find_signifier( \
    (N-1)//num_permutations+1, num_words_in_group, num_words_in_all \
)
# These are the words in the Nth permutation:
current_words = []
# Loop through current_signifier
for i in range(num_words_in_all):
    # If this bit is 1, add the corresponding word:
    if ((current_signifier & (1 << i)) >> i) == 1:
        current_words.append(words[i])

# Generate all permutations of current_words:
# NOTE: This is the smallest, yet most time-worthy part of the algorithm.
# However, it can be shortened to num_words_in_group*log(num_words_in_group)
# using a segment tree.
import itertools
perms = itertools.permutations(current_words)
# Print the one corresponding to (N-1) % num_permutations:
for i, perm in enumerate(perms):
    if i == (N-1) % num_permutations:
        print("The "+str(N)+"th permutation is", perm)
        break

Let $k$ be the number of words in a group and $n$ be the number of words in all, so in this case $k=3$ and $n=6$. Now, find_signifier function is $O(n^2)$ because of the for loop and recursion, calculating num_permutations takes $O(k)$, the for loop after finding current_signifier is $O(n)$, and the last part is a brute force $O(k!)$, so we get:
$$O(n^2+k+n+k!)=O(n^2+k!)$$
However, there is an ad hoc way to get the last part down to $O(k^2)$ and using a segment tree, we can get it down to $O(k\log k)$, so $O(n^2+k\log k)$ is the fastest algorithm that I can come up with.
A: There are $n(n-1)(n-2)$ permutations of three letters from $n$.  The first step is to find which block you are in.  For example $6 \cdot 5 \cdot 4=120, 7 \cdot 6 \cdot 5=210$ so if $120 \lt N \le 210$ you have used up all the permutations using the first six words ($ABCDEF$) and are working through the $90$ permutations that include $G$. I will generate them in the following order: take the combinations of two words from $ABCDEF$ in alphabetic order, group them with $G$, and list the six permutations of the group before moving on to the next group.  Let us use $N=195$ for our example.  This is the $195-120=75th$ word in the group including $G$.  We want the $\lfloor \frac {75-1}6 \rfloor +1=13th$ combination of two letters from $ABCDEF$.  $A$ has five, $B$ has four, $C$ has three, so we want $DEG$  Each preceding combination generate six permutation, so they have generated $120+12\cdot 6=192$ permutations and we want the third of $DEG$, which is $EDG$, your target.
