元ネタ

List<string> pptp = new List<string>(){"ポ", "プ", "テ", "ピピック"};
Random r = new Random();

Queue<string> queue = new Queue<string>();
Queue<string> resultQueue = new Queue<string>();

IEnumerable<string> PPTP(Random r)
{
    while(true)
    {
        yield return pptp[r.Next(pptp.Count)];
    }
}
void Main()
{

    foreach(var elem in PPTP(r))
    {
        queue.Enqueue(elem);
        resultQueue.Enqueue(elem);
        if(queue.Count >= 4)
        {
            if(queue.Zip(pptp, (first, second) => first.Equals(second)).All(x => x))
            {
                Console.WriteLine(resultQueue);
                break;
            }
            queue.Dequeue();
        }
    }
}
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.