Something in the Box?

Published by Helen Yu in

Create a function that returns true if an asterisk * is inside a box.

Examples

in_box([
  "###",
  "#*#",
  "###"
]) ➞ true

in_box([
  "####",
  "#* #",
  "#  #",
  "####"
]) ➞ true

in_box([
  "*####",
  "# #",
  "#  #*",
  "####"
]) ➞ false

in_box([
  "#####",
  "#   #",
  "#   #",
  "#   #",
  "#####"
]) ➞ false

Notes

The asterisk may be in the array, however, it must be inside the box, if it exists.

Watch a quick demo on how Edabit works.