The hint offers clear instructions how to iteratively generate longer and longer sequences matching the desired pattern. This means your main function needs to:
- declare a container to hold the sequence
- initialize it to hold the minimal sequence: '2' (the problem description doesn't actually state that, but just '2' will work!)
- write a loop to repeatedly replace your pattern with a new one
- print out the current pattern after each sequence
Start with this code and implement the functions:
#include <vector>
#include <iostream>
std::vector<int> nextPattern(const std::vector<int>& pattern) {
std::vector<int> next_pattern;
return next_pattern;
}
void printvec(std::vector<int> vec) {
}
int main() {
std::vector<int> pattern {2};
for (int i = 0; i < 4; ++i) {
pattern = nextPattern(pattern);
printvec(pattern);
}
}
If you do it right you should get (the last line is
_very_ long!):
2,3,3,2,
2,3,3,2,3,3,3,2,3,3,3,2,3,3,2,
2,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,2,
2,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,3,2,3,3,2,3,3,3,2,3,3,3,2,3,3,2