11 int combinations = 3 * (int)pow(2, n - 1);
16 int starting_with_the_same_letter = combinations / 3;
20 if (k <= starting_with_the_same_letter)
22 else if (k > starting_with_the_same_letter && k <= 2 * starting_with_the_same_letter)
28 k = k % starting_with_the_same_letter;
30 k = starting_with_the_same_letter;
33 int half = starting_with_the_same_letter / 2;
34 for (
int i = 1; i < n; ++i)
36 char prev_char = result.back();
37 char first_choice, second_choice;
56 result += first_choice;
59 result += second_choice;