Created
October 23, 2023 01:27
-
-
Save unilecs/06daa2fc302d2b7f0f1630b8d4c523df to your computer and use it in GitHub Desktop.
Задача: Квадрад слов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public static bool CheckWordSquare(List<string> words) | |
{ | |
int len = words.Count; | |
for(int i = 0; i < len; i++) | |
{ | |
for(int j = 0; j < words[i].Length; j++) | |
{ | |
if (j >= len || words[j].Length <= i || words[j][i] != words[i][j]) | |
return false; | |
} | |
} | |
return true; | |
} | |
public static void Main() | |
{ | |
Console.WriteLine("UniLecs"); | |
// tests | |
Console.WriteLine(CheckWordSquare(new List<string>() { "abcd", "bnrt", "crm", "dt" })); // true | |
Console.WriteLine(CheckWordSquare(new List<string>() { "ball","area","read","lady" })); // false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment