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