using System;
class Program
{
static bool MatchesPattern(string pattern, string sentence) {
string[] words = sentence.Split(
new[] { ' ' },
StringSplitOptions.RemoveEmptyEntries
);
// Length mismatch → automatic failure
if (pattern.Length != words.Length)
return false;
// Compare each pattern character to the first letter of each word
for (int i = 0; i < pattern.Length; i++) {
char p = char.ToLower(pattern[i]);
char w = char.ToLower(words[i][0]);
if (p != w)
return false;
}
return true;
}
static void Main()
{
string pattern = "jpcrg";
string sentence = "java python c rust go";
if (MatchesPattern(pattern, sentence))
Console.WriteLine("Pattern matches!");
else
Console.WriteLine("Pattern does NOT match.");
}
}
/*
run:
Pattern matches!
*/