Backstory
You own a tiny jewellery shop in the suburbs of the city. The suburbs are too much overpopulated, so your shop has a thickness of only one character to fit in the busy streets.
Recently, there has been lots of cases of robbery on the neighborhood, and you fear that robbers will also come to get your bounty.
Therefore, you installed surveillance cameras to take care of the shop. But there is one big problem: The cameras do not beep or alarm.
You decide to program the security alarm by yourself. This will complete the contraptions and (hopefully) make your little shop safe and secure.
Task
Your surveillance cameras will map your shop like this:
WI J E W
This is your input, which you can take from STDIN or from the command-line arguments. Each of the letters have different meanings.
- W represents a wall. Robbers and intruders cannot pass through them.
- E means employees. These are the beings that the cameras recognise. If they see an intruder, they will immediately set off the alarm before the robbers can do anything. (They can see an intruder if there is no wall, jewel, intruder or other employee in between) They also tend to stand still.
- J means jewels. These are the stuff the robbers and intruders are looking for.
- I means intruder. They are most likely robbers. Their goal is to steal (at least one of) the jewels of the shop.
- Of course, you can create your own legend of the map for the sake of saving code bytes.
Based on the input, you need to write a program (or function) that does the following:
- If an intruder can freely put their hands on a jewel OR an employee can see an intruder:
- Print a truthy value. ("1", "True", "Alert")
- To be completely alert, print the ASCII bell character. (It has an ASCII code of 7. When printed, it plays a ting sound on lots of computers and implementations)
- In most implementations, there cannot be a ting sound, so be carefull!
- In some cases where the bell absolutely cannot be printed, print an exclamation ('!') instead of it. (Printing exclamation marks may be harder to implement in some languages)
- Else:
- Print a falsey value. ("0", "False", "Quiet")
- If an intruder can freely put their hands on a jewel OR an employee can see an intruder:
The shop does not wrap around.
Welp, your computer runs slow when you run too much bytes. Try to program your code as short as possible. (
code-golf
)
Example tests
STDIN: EXAMPLE STDOUT:WI J E W 1(BEL)WIWWJWE W 0E I J I E 1(BEL)I W J E 0I E W E E 1(BEL)IIIIEIIII 1(BEL)JJJJEJJWI 0
Note: "(BEL)" refers to the bell character, not the string.