What’s on the Grille

From programming_contest
Jump to navigation Jump to search

This problem asks you to decrypt a message written on a grid using a rotating "keyhole."

There isn't much challenge here other than some implementation tricks to make everything smooth

  1. parse the r,c indices of the "holes" in the input grid.
    • check that there are n holes
  2. read out the characters in the string at the appropriate places (hint: it's r*n+c)
  3. mark the letter as "read"
  4. rotate the grid
    • this is accomplished by mapping (r,c) to (c, 3-r) (0,1 -> 1,3 -> 3,2 -> 2,0)
  5. resort the elements
    • a custom comparator makes this trivial
  6. repeat 4 times total

If you ever attempt to read a letter which was already read, fail.