Day 3 Part 1
This commit is contained in:
parent
2c7e21b098
commit
5533ef2b25
|
|
@ -7,8 +7,8 @@ using namespace std;
|
|||
int main() {
|
||||
cout << "Advent of Code 2021 - Day 3 Part 1" << endl;
|
||||
|
||||
unsigned char gamma[12] = {0};
|
||||
unsigned char epsilon[12] = {0};
|
||||
unsigned int gamma = 0;
|
||||
unsigned int epsilon = 0;
|
||||
|
||||
vector<vector<char>> inputBits;
|
||||
|
||||
|
|
@ -36,22 +36,15 @@ int main() {
|
|||
}
|
||||
|
||||
if(greater > (inputBits.size() / 2)) {
|
||||
gamma[x] = 1;
|
||||
epsilon[x] = 0;
|
||||
gamma |= 1UL << 11 - x;
|
||||
} else {
|
||||
gamma[x] = 0;
|
||||
epsilon[x] = 1;
|
||||
epsilon |= 1UL << 11 - x;
|
||||
}
|
||||
}
|
||||
|
||||
int asd = 0;
|
||||
|
||||
for(int x = 0; x < 12; x++) {
|
||||
asd = asd << (int)gamma[x];
|
||||
}
|
||||
cout << asd << endl;
|
||||
|
||||
cout << gamma << endl;
|
||||
cout << epsilon << endl;
|
||||
cout << gamma * epsilon << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user