using System.Collections.Generic;
private static readonly HashSet<char> vowels = new HashSet<char> { 'A', 'E', 'I', 'O', 'U' };
Console.WriteLine("=== Vowel Skewer Authenticator ===\n");
Console.WriteLine("Choose an option:");
Console.WriteLine("1. Test a skewer");
Console.WriteLine("2. See explanation of rules");
Console.WriteLine("3. Run example tests");
Console.WriteLine("4. Exit");
Console.Write("\nEnter your choice (1-4): ");
string choice = Console.ReadLine();
Console.WriteLine("Thanks for using the Vowel Skewer Authenticator!");
Console.WriteLine("Invalid choice. Please enter 1, 2, 3, or 4.\n");
static void TestUserSkewer()
Console.Write("Enter your skewer string: ");
string input = Console.ReadLine()?.ToUpper() ?? string.Empty;
bool result = IsAuthenticSkewer(input);
string resultText = result ? "AUTHENTIC" : "NOT AUTHENTIC";
Console.WriteLine($"\nResult: {resultText}");
Console.WriteLine("Reason: " + GetFailureReason(input));
static void ShowExplanation()
Console.WriteLine("=== Authentic Vowel Skewer Rules ===");
Console.WriteLine("An authentic vowel skewer must satisfy ALL of these conditions:");
Console.WriteLine("1. STRUCTURE: Must contain letters separated by dashes");
Console.WriteLine(" - Cannot be empty or contain only dashes");
Console.WriteLine(" - Must have actual letters (A-Z)");
Console.WriteLine("2. START & END: Must begin and end with a CONSONANT");
Console.WriteLine(" - Consonants: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z");
Console.WriteLine(" - Vowels: A, E, I, O, U");
Console.WriteLine("3. ALTERNATING PATTERN: Must alternate between consonants and vowels");
Console.WriteLine(" - Pattern: Consonant → Vowel → Consonant → Vowel → ...");
Console.WriteLine("4. CONSISTENT SPACING: All letters must be separated by the same number of dashes");
Console.WriteLine(" - Valid: 'B-A-N' (1 dash) or 'B--A--N' (2 dashes)");
Console.WriteLine(" - Invalid: 'B-A--N' (inconsistent spacing)");
Console.WriteLine("Examples:");
Console.WriteLine("✓ 'B--A--N--A--N--A--S' - All rules satisfied");
Console.WriteLine("✗ 'A--X--E' - Starts with vowel");
Console.WriteLine("✗ 'C-L-A-P' - Two consonants in a row (C-L)");
Console.WriteLine("✗ 'M--A---T-E-S' - Inconsistent spacing");
static void RunExampleTests()
Console.WriteLine("=== Running Example Tests ===");
("B--A--N--A--N--A--S", true, "Perfect authentic skewer"),
("A--X--E", false, "Starts with vowel"),
("C-L-A-P", false, "Two consonants in a row"),
("M--A---T-E-S", false, "Inconsistent spacing"),
("", false, "Empty string"),
("---", false, "Only dashes"),
("B", false, "Single letter, no dashes"),
("B-A", true, "Simple valid skewer"),
("B-A-T", true, "Three letters, valid pattern"),
("B-E-A-T", false, "Ends with vowel"),
foreach (var (skewer, expected, description) in testCases)
bool actual = IsAuthenticSkewer(skewer);
string status = actual == expected ? "✓ PASS" : "✗ FAIL";
string resultText = actual ? "AUTHENTIC" : "NOT AUTHENTIC";
Console.WriteLine($"{status} | '{skewer}' → {resultText}");
Console.WriteLine($" | {description}");
Console.WriteLine($" | Expected: {(expected ? "AUTHENTIC" : "NOT AUTHENTIC")}");
public static bool IsAuthenticSkewer(string skewer)
if (string.IsNullOrEmpty(skewer)) return false;
var letters = new List<char>();
var dashGroups = new List<int>();
while (i < skewer.Length)
if (char.IsLetter(skewer[i]))
while (i < skewer.Length && skewer[i] == '-')
dashGroups.Add(dashCount);
if (letters.Count == 0) return false;
if (letters.Count > 1 && dashGroups.Count == 0) return false;
if (letters.Count == 1 && skewer.Length == 1) return false;
if (dashGroups.Count > 0)
int expectedDashes = dashGroups[0];
if (expectedDashes == 0) return false;
if (dashGroups.Any(count => count != expectedDashes))
if (IsVowel(letters[0]) || IsVowel(letters[letters.Count - 1]))
for (int j = 0; j < letters.Count - 1; j++)
bool currentIsVowel = IsVowel(letters[j]);
bool nextIsVowel = IsVowel(letters[j + 1]);
if (currentIsVowel == nextIsVowel)
private static bool IsVowel(char c)
return vowels.Contains(char.ToUpper(c));
private static string GetFailureReason(string skewer)
if (string.IsNullOrEmpty(skewer))
return "Empty or null string";
var letters = new List<char>();
var dashGroups = new List<int>();
bool hasInvalidChar = false;
while (i < skewer.Length)
if (char.IsLetter(skewer[i]))
while (i < skewer.Length && skewer[i] == '-')
dashGroups.Add(dashCount);
else if (skewer[i] != '-')
return "Contains invalid characters (only letters and dashes allowed)";
return "No letters found";
if (letters.Count == 1 && skewer.Length == 1)
return "Single letter without dashes is not a skewer";
if (dashGroups.Count > 0)
int expectedDashes = dashGroups[0];
return "Letters must be separated by at least one dash";
if (dashGroups.Any(count => count != expectedDashes))
return "Inconsistent spacing between letters";
return "Must start with a consonant";
if (IsVowel(letters[letters.Count - 1]))
return "Must end with a consonant";
for (int j = 0; j < letters.Count - 1; j++)
bool currentIsVowel = IsVowel(letters[j]);
bool nextIsVowel = IsVowel(letters[j + 1]);
if (currentIsVowel == nextIsVowel)
string type = currentIsVowel ? "vowels" : "consonants";
return $"Two {type} in a row at positions {j + 1} and {j + 2} ('{letters[j]}' and '{letters[j + 1]}')";