MCPcopy Create free account
hub / github.com/Gecode/gecode / mineField

Function mineField

examples/minesweeper.cpp:288–303  ·  view source on GitHub ↗

Return value at position (\a i,\a j) in the example \a s of size \a n

Source from the content-addressed store, hash-verified

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

Callers 2

MineSweeperMethod · 0.85
printMethod · 0.85

Calls 1

spec_sizeFunction · 0.85

Tested by

no test coverage detected