17
1
This is my pet emoji, Billy:
-_-
Emojis don't like to be in the rain, so Billy is sad... Let's draw him an umbrella to make him feel better!
/\
/ \
/ \
-_-
This is good, he is entirely covered by his umbrella! Here is an example where only part of him is covered:
/\
/ \
/ \
-_-
In this case, sections 2 and 3 of his body are exposed to the rain.
Umbrellas come in many shapes and sizes, but they're always made up from a series of ascending slashes /
followed by a series of descending backslashes \
. For example, these are all valid umbrellas:
/\
/ \
/ \
/\
/\
/ \
/ \
/ \
/ \
And these are not:
/ \
\/
\
/ \
/ \
0\
/ \
//\\
/ \
You need to determine which parts of my emoji are exposed to the rain.
Clarifications
Your program (or function) will take a 2d string as input. This can be in whatever format is most convenient or natural to your language. An array of strings, an array of arrays of characters, a string with newlines in it etc.
You must output which sections of the emoji are exposed to the rain. This can be zero-indexed or one-indexed, as long as you make this clear. Output can be in any reasonable format. If the entire emoji is protected from the rain, output nothing (or an empty array).
You can assume that all inputs will have a valid umbrella, and the same emoji:
-_-
. The emoji will always be on the last line of the input, however their might be several empty lines between the umbrella and the emoji.Everything that isn't part of the umbrella or the emoji will be a space
character or newline.
The input will be padded with spaces so that the length of each line is the same.
Standard loopholes apply, and the shortest answer in bytes wins!
Test IO:
All of the sample cases will use one-indexing.
/\
/ \
/ \
-_-
Outputs: []
----------------
/\
/ \
-_-
Outputs: [2, 3]
----------------
/\
-_-
Outputs: [1]
----------------
/\
/ \
/ \
/ \
/ \
/ \
-_-
Outputs: [1, 2, 3]
2Can we output the parts of the emoji that are in the rain? i.e.
["_","-"]
. – Rɪᴋᴇʀ – 2016-06-11T14:35:47.140If our language supports strings, can we still accept a 2D array of characters? For example, Array in JavaScript has different functions available to it than String does. – Patrick Roberts – 2016-06-14T17:09:33.230
@PatrickRoberts Yes, that is acceptable. – James – 2016-06-14T17:14:36.780
@EᴀsᴛᴇʀʟʏIʀᴋ No, you should output the numbers. – James – 2016-06-14T17:15:21.520
1I think you mean emoticon. Dry emoji would be (or ☂️ I suppose) – NH. – 2019-05-09T19:01:32.633