Type an input and write what you think is the output . Each problem is converted to Web Assembly, so any possible input will show the corresponding output. Only correct predictions count.
Locked until you have predicted 4 outputs correctly.
| 1 | bool solution(const vector<string>& board) { |
| 2 | |
| 3 | set<pair<int, char>> rows; |
| 4 | set<pair<int, char>> cols; |
| 5 | set<pair<int, char>> boxes; |
| 6 | |
| 7 | for (int r = 0; r < 9; r++) { |
| 8 | for (int c = 0; c < 9; c++) { |
| 9 | |
| 10 | char d = board[r][c]; |
| 11 | |
| 12 | if (d == '.') { |
| 13 | continue; |
| 14 | } |
| 15 | |
| 16 | int b = (r / 3) * 3 + c / 3; |
| 17 | |
| 18 | if (!rows.insert({r, d}).second) { |
| 19 | return false; |
| 20 | } |
| 21 | |
| 22 | if (!cols.insert({c, d}).second) { |
| 23 | return false; |
| 24 | } |
| 25 | |
| 26 | if (!boxes.insert({b, d}).second) { |
| 27 | return false; |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return true; |
| 33 | } |
Names have been stripped. The signature is the only clue you get for free. Compiled as C++20 with the standard headers and using namespace std; already in scope.