Creating a Picture Frame

Published by persolut in

Create a function that takes the width, height and character and returns a picture frame as an array of strings (string[]).

Examples

get_frame(4, 5, "#") ➞ [
  "####",
  "#  #",
  "#  #",
  "#  #",
  "####"
]
// Frame is 4 characters wide and 5 characters tall.


get_frame(10, 3, "*") ➞ [
  "**********",
  "*        *",
  "**********"
]
// Frame is 10 characters and wide and 3 characters tall.


get_frame(2, 5, "0") ➞ "invalid"
// Frame's width is less than 3.

Notes

  • Remember the gap.
  • Return ["invalid"] if width or height is less than 3 (can't put anything inside).
Watch a quick demo on how Edabit works.