Find all words in a 2D array of characters

This problem asks us to find all the words in a 2D array of characters. The input is a 2D array of characters, and the output is a list of strings containing all the words in the array.


Given a 2D array of characters, find all the words in the array.
["abcd", "efgh", "ijkl", "mnop"]


This solution is in C#. Our A.I. can create solutions in multiple languages.
by kayakane
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            char[,] input = new char[4, 4] { { 'a', 'b', 'c', 'd' }, { 'e', 'f', 'g', 'h' }, { 'i', 'j', 'k', 'l' }, { 'm', 'n', 'o', 'p' } };
            List<string> output = new List<string>();
            for (int i = 0; i < input.GetLength(0); i++)
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < input.GetLength(1); j++)
                    sb.Append(input[i, j]);
            Console.WriteLine(string.Join(",", output ));

A.I. Evaluation of the Solution

The candidate's solution correctly solves the problem. The candidate uses a StringBuilder to construct the words from the 2D array, which is a good approach. The candidate's code is also clean and easy to read.

Evaluated at: 2022-12-02 10:15:48