Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "input.h"
- #include <bits/stdc++.h>
- using namespace std;
- int countTrees(int movX, int movY)
- {
- const int numberOfRows = maps.size();
- const int numberOfColumns = maps[0].length();
- int x = 0, y = 0;
- int treeCount = 0;
- while (y < maps.size())
- {
- const int readX = x % numberOfColumns;
- char character = maps[y][readX];
- if (character == '#')
- {
- treeCount++;
- }
- x += movX;
- y += movY;
- }
- cout << "treeCount: " << treeCount << endl;
- return treeCount;
- }
- int main()
- {
- const int movX = 3, movY = 1;
- long productOfTrees = 1;
- int n1 = countTrees(1, 1); //79
- int n2 = countTrees(3, 1); //216
- int n3 = countTrees(5, 1); //91
- int n4 = countTrees(7, 1); //96
- int n5 = countTrees(1, 2); //45
- productOfTrees = n1 * n2 * n3 * n4 * n5;
- //productOfTrees = (countTrees(1, 1) * countTrees(3, 1) * countTrees(5, 1) * countTrees(7, 1) * countTrees(1, 2));
- cout << productOfTrees;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement