Perfect Square Patch

Published by mqqqqqx in

Create a function that takes an integer and outputs an n x n square solely consisting of the integer n.

Examples

SquarePatch(3) ➞ [
  [3, 3, 3],
  [3, 3, 3],
  [3, 3, 3]
]

SquarePatch(5) ➞ [
  [5, 5, 5, 5, 5],
  [5, 5, 5, 5, 5],
  [5, 5, 5, 5, 5],
  [5, 5, 5, 5, 5],
  [5, 5, 5, 5, 5]
]

SquarePatch(1) ➞ [
  [1]
]

SquarePatch(0) ➞ []

Notes

  • n >= 0.
  • If n = 0, return an empty array.
Watch a quick demo on how Edabit works.