Return value at position (\a i,\a j) in the example \a s of size \a n
| 286 | |
| 287 | /// Return value at position (\a i,\a j) in the example \a s of size \a n |
| 288 | int mineField(const char *s, int n, int i, int j) { |
| 289 | assert(spec_size(s) == n); |
| 290 | assert(i >= 0 && i < n); |
| 291 | assert(j >= 0 && j < n); |
| 292 | char c = s[i*n + j]; |
| 293 | if (!std::isalnum(c)) |
| 294 | return -1; |
| 295 | if (std::isdigit(c)) |
| 296 | return c - '0'; |
| 297 | if (std::islower(c)) |
| 298 | c = static_cast<char>(std::toupper(c)); |
| 299 | // std::alpha(c) == true |
| 300 | int res = (c - 'A') + 10; |
| 301 | if (res > n) return 0; |
| 302 | else return res; |
| 303 | } |
| 304 | //@} |
| 305 | } |
| 306 |
no test coverage detected