// this is my own example
#include <iostream>
#include <string>

using namespace std;

int count_uppercase(string s){
    int count = 0;
    while (s.length() > 0){
        if (isupper(s[0])){
            count++;
        }
        s = s.substr(1);
    }
    return count;
}
#include <iostream>
#include <string>

using namespace std;
int count_uppercase(string s){
    int count = 0;
    for (char c : s){
        if (isupper(c)) count++;
    }
    return count;
}

two ninja

print all possible combinations & and _

  1. They can't stand on the first or last tile
  2. They need to keep a distance away
  3. They can’t jump over each other, which means the ninja’s left-to-right order must be maintained.

Print all possible combinations of the stand of the ninja

e.g. for size 5 is

#include <iostream>
#include <string>

using namespace std;

void printtails(int size){
    if (size<5) return;
    string b(size, '_');
    for (int i = 1; i < size - 1; i++) {
        b[i] = '&';
        for (int j = i + 2; j < size - 1; j++) {
            b[j] = '&';
            cout << b << endl;
            b[j] = '_';
        }
        b[i] = '_';
    }

}

int main(){
    int size = 10;
    printtails(size);
}

for(int i = 1; i < n-1; ++i){
    for(int j = i+2; j < n-1; ++j){
        string s(n, '_');
        s[i] = s[j] = '&';
        cout << s << '\\n';
    }
}