diff --git a/2017/day-01/input.txt b/2017/day-01/input.txt new file mode 100644 index 0000000..da73c13 --- /dev/null +++ b/2017/day-01/input.txt @@ -0,0 +1 @@ +3893445835429722678558456317563893861752455542588369533636585887178232467588827193173595918648538852463974393264428538856739259399322741844613957229674619566966921656443476317729968764183945899765294481327998956154956571467872487576314549468261122281384513266834769436913544431258253346374641589492728885222652146158261225296144835682556133922436438188211288458692217737145834468534829945993366314375465767468939773939978272968388546791547526366348163672162245585168892858977723516752284597322176349412485116173844733679871253985762643852151748396593275274582481295864991886985988427966155944392352248314629138972358467959614279553511247863869663526823326467571462371663396188951696286916979923587358992127741723727623235238531991996999181976664226274715591531566495345212849683589582225465555847312199122268773923175183128124556249916458878785361322713513153175157855597289482439449732469754748544437553251412476225415932478849961897299721228198262823515159848941742786272262236888514421279147329383465929358896761449135917829473321834267122759371247338155787774952626616791265889922959653887288735233291968146648533754958199821789499914763279869931218136266492627818972334549751282191883558361871277375851259751294611921756927694394977764633932938573132221389861617195291742156362494769521829599476753198422283287735888197584327719697758442462886311961723849326959213928195182293316227334998926839139915138472514686689887874559367524254175582135318545912361877139367538434683933333264146289842238921989275112323681356256979576948644489986951538689949884787173194457523474156229389465725473817651516136514446513436419126533875125645855223921197481833434658264655912731133356464193251635637423222227273192628825165993827511625956856754776849919858414375874943572889154281862749595896438581889424559988914658387293414662361364793844213298677236787998677166743945812899526292132465751582925131262933636228593134861363493849168168765261647652342891576445292462341171477487223253795935253493869317616741963486473 diff --git a/2017/day-01/solution.cpp b/2017/day-01/solution.cpp new file mode 100644 index 0000000..0ddc8b3 --- /dev/null +++ b/2017/day-01/solution.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +using namespace std; + +void get_sum(const string& data, const unsigned int offset) +{ + int sum = 0; + const auto total = data.size(); + for (auto i = 0u; i < total; ++i) { + if (data[i] == data[(i + offset) % total]) { + sum += data[i] - '0'; + } + } + + cout << "Sum: " << sum << endl; +} + +int main() +{ + string data; + cin >> data; + + get_sum(data, 1); + get_sum(data, data.size() / 2); + + return 0; +}