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

@@ -9,8 +9,9 @@
* \param s String to parse, must be L2 characters long
* \return Position described by s.
*/
template <unsigned L2, char LOWER, char UPPER>
unsigned find_pos(std::string const &s) {
template<unsigned L2, char LOWER, char UPPER>
unsigned find_pos(std::string const& s)
{
assert(s.length() == L2);
unsigned low = 0;
unsigned high = 1 << L2;
@@ -20,9 +21,11 @@ unsigned find_pos(std::string const &s) {
assert(width != 0);
if (c == LOWER) {
high = low + width;
} else if (c == UPPER) {
}
else if (c == UPPER) {
low = low + width;
} else {
}
else {
assert(false);
}
width >>= 1;
@@ -32,13 +35,15 @@ unsigned find_pos(std::string const &s) {
return low;
}
template <unsigned L2R, unsigned L2C> struct Seat {
Seat(std::string const &s) {
template<unsigned L2R, unsigned L2C>
struct Seat
{
Seat(std::string const& s)
{
assert(s.length() == L2R + L2C);
row_ = find_pos<L2R, 'F', 'B'>(s.substr(0, L2R));
col_ = find_pos<L2C, 'L', 'R'>(s.substr(L2R, L2C));
std::cout << s << ": row " << row_ << ", column " << col_ << ", seat ID "
<< id() << ".\n";
std::cout << s << ": row " << row_ << ", column " << col_ << ", seat ID " << id() << ".\n";
}
unsigned id() const noexcept { return row_ * (1 << L2C) + col_; }
@@ -47,7 +52,8 @@ template <unsigned L2R, unsigned L2C> struct Seat {
unsigned col_;
};
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
unsigned max_id = 0;
for (std::string line; std::getline(std::cin, line);) {