#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
bool compare(const string &a, const string &b)
{
int round1 = 0, round2 = 0, square1 = 0, square2 = 0, curly1 = 0, curly2 = 0;
for (auto &el : a)
{
if (el == '(' || el == ')')
{
round1++;
}
else if (el == '[' || el == ']')
{
square1++;
}
else
{
curly1++;
}
}
for (auto &el : b)
{
if (el == '(' || el == ')')
{
round2++;
}
else if (el == '[' || el == ']')
{
square2++;
}
else
{
curly2++;
}
}
if (round1 < round2)
{
return true;
}
else if (round1 > round2)
{
return false;
}
else if (square1 < square2)
{
return true;
}
else if (square1 > square2)
{
return false;
}
else
{
return curly1 < curly2;
}
}
vector<string> exercise2()
{
vector<string> tab;
string line;
ifstream file("../../../../assets/parentheses.txt");
while (file >> line && !file.eof())
{
tab.push_back(line);
}
file.close();
sort(tab.begin(), tab.end(), compare);
return tab;
}