Add .clang-format and apply it

This commit is contained in:
2021-12-02 07:18:16 +00:00
parent e58dede1b6
commit cd5e2538df
103 changed files with 2714 additions and 2132 deletions

View File

@@ -10,30 +10,31 @@
#include <string>
#include <variant>
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
std::multimap<std::string, std::string> replacements;
bool collecting_replacements = true;
std::string line;
while (std::getline(std::cin, line)) {
if (line.empty()) {
collecting_replacements = false;
} else if (collecting_replacements) {
}
else if (collecting_replacements) {
auto sep = line.find(" => ");
replacements.insert({line.substr(0, sep), line.substr(sep + 4)});
} else {
}
else {
std::set<std::string> new_molecules;
for (unsigned pos = 0; pos < line.size(); ++pos) {
auto [it, ite] = replacements.equal_range(line.substr(pos, 1));
while (it != ite) {
new_molecules.insert(line.substr(0, pos) + it->second +
line.substr(pos + 1));
new_molecules.insert(line.substr(0, pos) + it->second + line.substr(pos + 1));
++it;
}
if (pos < line.size() - 1) {
auto [it, ite] = replacements.equal_range(line.substr(pos, 2));
while (it != ite) {
new_molecules.insert(line.substr(0, pos) + it->second +
line.substr(pos + 2));
new_molecules.insert(line.substr(0, pos) + it->second + line.substr(pos + 2));
++it;
}
}