about summary refs log tree commit diff
path: root/day05.cc
blob: a5af122d47adc33ffc1fb899227b0809935da758 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <iterator>
#include <vector>

using namespace std;

int
main() {
	vector<int> v{istream_iterator<int>(cin), {}};
	auto w = v;
	int p1 = 0, p2 = 0;

	for (unsigned int pc = 0; pc < v.size(); p1++)
		pc += v[pc]++;

	for (unsigned int pc = 0; pc < v.size(); p2++)
		pc += w[pc] >= 3 ? w[pc]-- : w[pc]++;

	cout << p1 << endl << p2 << endl;
}