Match coordinates with their values

Python, 39 bytes

Takes the inputs:

  1. a list of (x, y) integer coordinates
  2. b list of strings
  3. c single character string

lambda a,b,c:{b[y][x]for x,y in a}=={c}

Octave, 45 38 29 bytes

@(A,B,C)A(1+B*[rows(A);1])==C

A function that takes a 2D array of chars as A and coordinates(0 based) B as a two column matrix of [col row] and the matching character as C. The two element coordinates(using matrix multiplication) converted to linear index.

Note: Previous answer that made use of sparse matrix was wrong.

Other Contributors:

Stewie Griffin for saving 5 bytes noting that [0 1 0] can be regarded as false value!!

Luis Mendo for saving 2 bytes that ~0 == true and notification about sparse matrix.

Try it Online


JavaScript (ES6), 37 bytes

Takes the inputs:

  1. a array of [x, y] integer coordinates
  2. s array of strings
  3. c single character string

(a,s,c)=>a.every(([x,y])=>s[y][x]==c)