Skip to content

Commit f741f56

Browse files
committed
reference
1 parent c5cd19d commit f741f56

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/aoc18/day05.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
#include <iostream>
2-
#include <string>
32
#include <fstream>
43
#include <streambuf>
54
#include <stack>
65

76
using namespace std;
87

9-
bool isPair(char a, char b) {
8+
bool isPair(const char &a, const char &b) {
109
return abs(a - b) == 32;
1110
}
1211

13-
int part1(string s) {
12+
int part1(const string &s) {
1413
stack<char> st;
1514

16-
int i=0, count = 0;
15+
int i = 0, count = 0;
1716
while(s[i] != '\n'){
1817
if(st.empty() || !isPair(s[i], st.top())) {
1918
st.push(s[i]);
@@ -28,10 +27,10 @@ int part1(string s) {
2827
return count;
2928
}
3029

31-
int part2(string s, char ch) {
30+
int part2(const string &s, const char &ch) {
3231
stack<char> st;
3332

34-
int i=0, count = 0;
33+
int i = 0, count = 0;
3534
while(s[i] != '\n'){
3635
if(s[i] == ch || s[i] == ch - 32) {
3736
i++; continue;

0 commit comments

Comments
 (0)