Added older advents

This commit is contained in:
Jos van Goor 2022-12-01 13:46:47 +01:00
parent 8db2505049
commit 9cf858b860
78 changed files with 13807 additions and 0 deletions

View file

@ -0,0 +1,40 @@
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
size_t dubbles = 0;
size_t tripples = 0;
string buffer;
while(getline(cin, buffer))
{
bool twice = false;
bool thrice = false;
size_t letters[26] = { };
for (char c : buffer)
{
++letters[c - 'a'];
}
for (size_t idx = 0; idx < 26; ++idx)
{
if (letters[idx] == 2)
twice = true;
if (letters[idx] == 3)
thrice = true;
}
if (twice)
++dubbles;
if (thrice)
++tripples;
}
cout << "checsum: " << dubbles * tripples << "\n";
}