VOOZH about

URL: https://qiita.com/ruhiel/items/c98451e4700344654f25

⇱ ランダム出力でポプテピピック #C# - Qiita


👁 Image
1

Go to list of users who liked

2

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@ruhiel

ランダム出力でポプテピピック

1
Posted at

元ネタ

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();
		}
	}
}
1

Go to list of users who liked

2
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1

Go to list of users who liked

2