C++ Add Border
#include <string>
#include <vector>

std::vector<std::string> addBorder(std::vector<std::string> picture)
{
    picture.insert(picture.begin(), std::string(picture[0].size(), '*'));
    for (auto& row : picture) {
        row = "*" + row + "*";
    }
    picture.push_back(std::string(picture[0].size(), '*'));

    return picture;
}

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

C# Add Border
static string[] AddBorder(string[] picture)
{
    var rows = new List<string> { new string('*', picture[0].Length) };
    rows.AddRange(picture);

    for (int i = 0; i < rows.Count; i++)
    {
        rows[i] = $"*{rows[i]}*";
    }

    rows.Add(new string('*', rows[0].Length));

    return rows.ToArray();
}

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

Elixir Add Border
defmodule AddBorder do
  def add_border(picture) do
    border = String.duplicate("*", String.length(hd(picture)))
    wrapped = Enum.map(picture, fn row -> "*" <> row <> "*" end)

    [border] ++ wrapped ++ [border]
  end
end

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

Erlang Add Border
-module(add_border).
-export([add_border/1]).

add_border(Picture) ->
    Width = length(hd(Picture)),
    Border = lists:duplicate(Width + 2, $*),
    Bordered = [[$*] ++ Row ++ [$*] || Row <- Picture],
    [Border] ++ Bordered ++ [Border].

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

Go Add Border
func addBorder(picture []string) []string {
	border := strings.Repeat("*", len(picture[0]))

	result := make([]string, 0, len(picture)+2)
	result = append(result, border)
	for _, line := range picture {
		result = append(result, "*"+line+"*")
	}
	result = append(result, border)

	return result
}

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

Haskell Add Border
addBorder :: [String] -> [String]
addBorder picture = border : map (\row -> "*" ++ row ++ "*") picture ++ [border]
  where
    border = replicate (length (head picture) + 2) '*'

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

Java Add Border
public class Solution {
    public static String[] addBorder(String[] picture) {
        int width = picture[0].length() + 2;
        String border = "*".repeat(width);

        String[] result = new String[picture.length + 2];
        result[0] = border;
        for (int i = 0; i < picture.length; i++) {
            result[i + 1] = "*" + picture[i] + "*";
        }
        result[result.length - 1] = border;

        return result;
    }
}

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

Lisp Add Border
(defun add-border (picture)
  (let* ((width (length (first picture)))
         (border (make-string width :initial-element #\*))
         (wrapped (mapcar (lambda (row) (format nil "*~A*" row))
                           (cons border picture))))
    (append wrapped (list (make-string (+ width 2) :initial-element #\*)))))

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

PHP Add Border
function addBorder($picture) {
    array_unshift($picture,str_repeat("*",strlen($picture[0])));
    foreach($picture as $k=> $v) {
        $picture[$k] = "*{$v}*";
    }
    $picture[] = str_repeat("*", strlen($picture[0]));
    return $picture;

}

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.

Python Add Border
def add_border(picture: list[str]) -> list[str]:
    width = len(picture[0]) + 2
    border = "*" * width
    return [border] + [f"*{row}*" for row in picture] + [border]

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.