9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

「進捗・どう・です・か」をランダムに表示し「進捗どうですか」が完成したら煽ってくるプログラム(C#/LINQ)

Last updated at Posted at 2015-07-17

「進捗・どう・です・か」をランダムに表示し「進捗どうですか」が完成したら煽ってくるClojure
「進捗・どう・です・か」をランダムに表示し「進捗どうですか」が完成したら煽ってくるプログラム
「進捗・どう・です・か」をHaskellで書いてみた
golang の進捗どうですか
「進捗・どう・です・か」をランダムに表示し「進捗どうですか」が完成したら煽ってくるプログラム(C#で挑戦)

ランダム生成を.OrderBy(x => Guid.NewGuid())で手抜きでやってみた。

Program.cs
using System;
using System.Linq;

namespace ShinchokuDoudesuka
{
    class Program
    {
        static void Main()
        {
            string[] words = { "進捗", "どう", "です", "か" };
            var count = 0;
            var tmp = "";
            while ((tmp = string.Join("", words.OrderBy(x => Guid.NewGuid())))
                != string.Join("", words))
            {
                Console.Write(tmp + " ");
                count++;
            }

            Console.WriteLine("");
            Console.WriteLine(@"
 _人人人人人人人_
 >進捗どうですか<
  ̄Y^Y^Y^Y^Y^Y^Y ̄");
            Console.WriteLine(count + "回で煽られました");
        }
    }
}

解釈を間違えていたようなので修正

Program.cs
using System;
using System.Linq;

namespace ShinchokuDoudesuka
{
    class Program
    {
        static void Main()
        {
            string[] words = { "進捗", "どう", "です", "か" };
            var tmp = "";
            var result = "";
            while (!result.EndsWith(string.Join("", words)))
            {
                Console.Write((tmp = words.OrderBy(x => Guid.NewGuid()).First()));
                result += tmp;
            }

            Console.WriteLine(@"

 _人人人人人人人_
 >進捗どうですか<
  ̄Y^Y^Y^Y^Y^Y^Y ̄");
            Console.WriteLine(result.Length + "文字で煽られました");
        }
    }
}
9
8
0

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
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?