Skip to content

Instantly share code, notes, and snippets.

@webuilder240
Last active May 17, 2020 02:47
Show Gist options
  • Save webuilder240/0d71b367134e9d85dbfacd1194f009e4 to your computer and use it in GitHub Desktop.
Save webuilder240/0d71b367134e9d85dbfacd1194f009e4 to your computer and use it in GitHub Desktop.
// https://twitter.com/i4mwh4ti4m/status/1258768719972454400?s=21
// しすすすすしおおおすし
// 11文字目でおすしがでました
using System;
using System.Collections.Generic;
namespace _3charsCharenge
{
class Program
{
static void Main(string[] args)
{
var result = "";
var rand = new Random();
List<string> l = new List<string>(){"お", "す" ,"し"};
var expect = string.Join("", l);
while(true)
{
var c = l[rand.Next(0, 3)];
result += c;
if (result.Contains(expect))
{
break;
}
}
Console.WriteLine(result);
Console.WriteLine($"{result.Length}文字目で{expect}がでました");
}
}
}
// https://twitter.com/i4mwh4ti4m/status/1258768719972454400?s=21
// しすすすすしおおおすし
// 11文字目でおすしがでました
using System;
using System.Collections.Generic;
namespace _3charsCharenge
{
class Program
{
static void Main(string[] args)
{
var result = "";
var rand = new Random();
List<string> l = new List<string>(){"お", "す" ,"し"};
var expect = string.Join("", l);
do
{
result += l[rand.Next(0, 3)];
} while (!result.Contains(expect));
Console.WriteLine(result);
Console.WriteLine($"{result.Length}文字目で{expect}がでました");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment