diff options
author | kaiwu <kaiwu2004@gmail.com> | 2022-03-14 17:19:04 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2022-03-14 17:19:04 +0800 |
commit | 582cd4c6b680fe9a32ad165b82db34bb60507fea (patch) | |
tree | 4838da58ac8e7ec1c0edab89a6fc3f48015ab6ac /src/2015/day1/aoc.cpp | |
parent | 644663969201ced8e32fe56c7d1fd712d2fa1330 (diff) | |
download | advent-of-code-582cd4c6b680fe9a32ad165b82db34bb60507fea.tar.gz advent-of-code-582cd4c6b680fe9a32ad165b82db34bb60507fea.zip |
next_line
Diffstat (limited to 'src/2015/day1/aoc.cpp')
-rw-r--r-- | src/2015/day1/aoc.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/2015/day1/aoc.cpp b/src/2015/day1/aoc.cpp index e69de29..2263558 100644 --- a/src/2015/day1/aoc.cpp +++ b/src/2015/day1/aoc.cpp @@ -0,0 +1,13 @@ +#include "aoc.h" + +namespace aoc2015 { + +int day1(line_view lv) { + int level = 0; + for (size_t i = 0; i < lv.length; ++i) { + level += lv.line[i] == '(' ? 1 : -1; + } + return level; +} + +} // namespace aoc2015 |