3
\$\begingroup\$

Given a drawing of the letter shoot system, where an existing piece of pipe is marked with a *, and an empty spot is marked with a ., your task is to compile a lexicographically sorted list of index tuples [entry row, entry column, exit row, exit column], where each index is 0-based. Entry and exit points are always on the border of the map. Mail can travel horizontally, vertically and diagonally and will usually maintain its direction, unless it is forced by the pipes to turn into a curve. Only 45 degree turns are possible -- the system is built in such a way that mail capsules will never get stuck.

It is guaranteed that pipes at the entry points have exactly one neighboring pipe, and that that neighbor is not on the same border as the entry point. It is also guaranteed that mail will eventually reach an exit point.

Example

For
pipesPlan = 
[[".",".","."], 
 ["*","*","*"], 
 [".",".","."]]

the output should be

airMail(pipesPlan) = [[1,0,1,2], [1,2,1,0]].

For

pipesPlan = 
[[".", ".", "*", ".", "."],
 [".", ".", "*", ".", "."],
 ["*", "*", "*", "*", "*"],
 [".", ".", "*", ".", "."],
 [".", ".", ".", "*", "."]]

the output should be

airMail(pipesPlan) = [[0,2,4,3], [2,0,2,4], [2,4,2,0], [4,3,2,0]].

[input] array.char pipesPlan

    The rectangular plan of pipes, where an * marks a piece of pipe and a. 
marks an empty spot.

[output] array.integer

    A lexicographically sorted list of tuples [entry row, entry column, 
exit row, exit column] that specify where a letter shot from entry row, 
entry column would end up according to the pipesPlan. Indices are 0-based.
\$\endgroup\$
6
  • 1
    \$\begingroup\$ Hi, and welcome to Programming Puzzles & Code Golf, nice first question, all that is required is a win condition, I would suggest shortest code in bytes for each language wins, adding the code-golf tag would be sufficient too. \$\endgroup\$ – LiefdeWen Dec 21 '17 at 12:09
  • 1
    \$\begingroup\$ Please do not immediately cv badly rephrased tasks that can be improved within a short time, it takes them forever to get reopened. \$\endgroup\$ – Uriel Dec 21 '17 at 12:19
  • 1
    \$\begingroup\$ @Uriel So what are close votes used for? Prevent answers to unclear challenges. About "it takes them forever to get reopened" - it's OP's fault for writing unclear challenge, and in my opinion it takes quite a short time if it's really clear. Ask on chat is also a good idea. \$\endgroup\$ – user202729 Dec 21 '17 at 12:29
  • 1
    \$\begingroup\$ @user202729, This is also a new user, I feel like we should cut him some slack and just maybe help him rephrase until we are happy. This question is literally just adding a tag away from being fine. \$\endgroup\$ – LiefdeWen Dec 21 '17 at 12:35
  • 1
    \$\begingroup\$ Welcome to PPCG! This is an interesting challenge, but it doesn't quite fit our expectations, as others have mentioned. I would suggest using The Sandbox to get feedback on future challenges. I'm looking forward to answering this and future challenges! \$\endgroup\$ – Giuseppe Dec 21 '17 at 12:45

Browse other questions tagged or ask your own question.