1
0
Fork 0
Advent2021/Day 3/Marcus/cpp/part1.cpp

18 lines
331 B
C++
Raw Permalink Normal View History

2021-12-03 22:50:09 +00:00
#include <iostream>
using namespace std;
int main()
{
string in;
int counts[12] = {0};
2021-12-04 03:58:07 +00:00
int result = 0;
2021-12-03 22:50:09 +00:00
2021-12-04 03:43:37 +00:00
while(cin >> in) for(int i = 0; i < 12; i++) result = ((counts[i] += (in[i]=='1')?1:-1)>0)?(result|1<<(11-i)):(result&~(1<<(11-i)));
2021-12-03 22:50:09 +00:00
cout << result*(result^0x0FFF) << endl;
return 0;
}