C# 谜中之谜,想不通

C# Puzzle within a puzzle, can't figure it out

我需要帮助解决这个 C# 难题:这是一个填空游戏,答案可以是以下 7 个空格之一

空白看起来像这样 _ 并突出显示并且有 7 个

拼图的下一部分是 在下面的代码中,我可以调用什么 C# 函数来替换 for 循环并插入以满足“结果 ==?”:

    var answer = "Please help me with this puzzle please"; 

    var words = new[] { "Please", "help", "me", "with", "this", "puzzle", "please" }; 

    var result = ?

    if ( result == answer )
    Console.WriteLine(“Correct!”);

我猜你需要某种 linq 查询来满足这个需求,但是怎么做呢?

我个人很震惊,因为我不是 C# 的粉丝

已解决。基本上只是尝试一些事情,其他一些事情是很合乎逻辑的(例如 while(wordCount < 4) 由于 wordCount 递增)。其他东西只是模运算的东西,这让挑战变得更加困难。 (比如 x % 1 总是 true)。

using System;

class Programm
{
    static void Main()
    {
        var answer = "Please help me with this puzzle please"; 
        var words = new[] { "Please", "help", "me", "with", "this", "puzzle", "please" };

        var result = "";
        var wordCount = 0;

        for (var iCount = 12; iCount > 0; iCount--)
        {
            while (wordCount < 4) //less than because word count get's incremented
            {
                if (iCount % 1 == 0)
                {
                    result += words[wordCount]; 
                    result += " ";
                    wordCount++;
                }

                if ((iCount * 6) == 24)
                {
                    result += words[wordCount]; 
                    result += " ";
                    wordCount++;
                }
                iCount--;
            }

            if (iCount % 3 != 1)
                continue;

            result += words[wordCount]; 

            if (wordCount != 6)
                result += " ";

            wordCount += 1;
        }

        Console.WriteLine("Result: " + result);

        if ( result == answer )
            Console.WriteLine("Correct!");
        else
            Console.WriteLine("FAIL!");
    }
}

这是问题的最后一部分:使用string.Join

    var answer = "Please help me with this puzzle please";

    var words = new[] { "Please", "help", "me", "with", "this", "puzzle", "please" };

    var result = string.Join(" ", words);

    if (result == answer)
        Console.WriteLine("Correct!");