-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
matrix_enclosed_regions.cc
46 lines (40 loc) · 1.25 KB
/
matrix_enclosed_regions.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdexcept>
#include <string>
#include <vector>
#include "test_framework/generic_test.h"
#include "test_framework/timed_executor.h"
using std::string;
using std::vector;
void FillSurroundedRegions(vector<vector<char>>* board_ptr) {
// TODO - you fill in here.
return;
}
vector<vector<string>> FillSurroundedRegionsWrapper(
TimedExecutor& executor, vector<vector<string>> board) {
vector<vector<char>> char_vector;
char_vector.resize(board.size());
for (int i = 0; i < board.size(); i++) {
for (const string& s : board[i]) {
if (s.size() != 1) {
throw std::runtime_error("String size is not 1");
}
char_vector[i].push_back(s[0]);
}
}
executor.Run([&] { FillSurroundedRegions(&char_vector); });
board.clear();
board.resize(char_vector.size(), {});
for (int i = 0; i < board.size(); i++) {
for (char c : char_vector[i]) {
board[i].emplace_back(1, c);
}
}
return board;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"executor", "board"};
return GenericTestMain(
args, "matrix_enclosed_regions.cc", "matrix_enclosed_regions.tsv",
&FillSurroundedRegionsWrapper, DefaultComparator{}, param_names);
}