#include "triangles.h"

bool check(int d, int n) {
    for (int a = 0; a < n; a++) {
        for (int b = 0; b < n; b++) {
            if (a == b) continue;
            for (int c = 0; c < n; c++) {
                if (a == c || b == c) continue;
                if (a == d || b == d || c == d) continue;
                if (compare({Triangle{a, b, d}, Triangle{c, b, d}, Triangle{a, c, d}}, {Triangle{a, b, c}}) == 0) {
                    return false;
                }
            }
        }
    }      
    return true;
}
std::vector<std::vector<int>> solve(int n) {
    if (n == 4) {
        for (int a = 0; a < 4; a++) {
            for (int b = 0; b < 4; b++) {
                if (a == b) continue;
                for (int c = 0; c < 4; c++) {
                    if (a == c || b == c) continue;
                    for (int d = 0; d < 4; d++) {
                        if (a == d || b == d || c == d) continue;
                        if (compare({Triangle{a, b, c}, Triangle{b, c, d}}, {Triangle{a, c, d}, Triangle{b, a, d}}) == 0) {
                            return {{a, b, c}, {b, c, d}};
                        }
                        if (compare({Triangle{a, b, d}, Triangle{c, b, d}, Triangle{a, c, d}}, {Triangle{a, b, c}}) == 0) {
                            return {{a, b, d}, {b, c, d}, {a, c, d}};
                        }
                    }
                }
            }
        }
        return {};
    }
    // int a = 0; int b = 1; int c = 2;
    // for (int i = 0; i < n ; i++) {
    //     if (i == a || i == b || i == c) continue;
    //     if (compare({Triangle{a, b, i}}, {Triangle{a, b, c}}) == 1) {
    //         c = i;
    //     }
    // }
    // for (int i = 0; i < n ; i++) {
    //     if (i == a || i == b || i == c) continue;
    //     if (compare({Triangle{a, i, c}}, {Triangle{a, b, c}}) == 1) {
    //         b = i;
    //     }
    // }
    // for (int i = 0; i < n ; i++) {
    //     if (i == a || i == b || i == c) continue;
    //     if (compare({Triangle{i, b, c}}, {Triangle{a, b, c}}) == 1) {
    //         a = i;
    //     }
    // }
    // return {{a, b, c}};
    std::vector<int> answer;
    for (int a = 0; a < n && answer.size(); a++) {
        if (check(a, n)) {
            answer.push_back(a);
        }
    }


    return {answer};
}
