たんばりんニュースブログ

当て付け怪文書海老ブログではない

ば解説「文字出現率分析と単一換字暗号の応用を用いたキャラクター使用分布リスト作成」

今回ば解説情報処理

ば作キャラ分布

ば集データ

ば集計準備

ばメモ上位250キャラ

然ば大変

ば立作戦

ばキャラ選択画面対応Myキーボード



故1頁5秒。速。



累計ポイント世界ランキング(1〜250位)
vgqfzqzzzruhqjzeduaqbgymcrmwzjmgbqfrcgmvgbzhhemuygvwnbugqwcvzveczhbmcnvxvnqqtmjsxzfestgnxezunbqsrzggrsnzgsjdebwzdxqbxzqzjvmfwtznbrzzfqcfsrafdnuuxhafrtgzhgbwhasbmrqwnmxqsqzrarhhmzhmzbdnszfvzushqntzggnwgfsturdwzqunedfbqmuzewxrtfcjgvnwvdqtwyezqxznrvmjtt

累計勝利数世界ランキング(1〜250位)
qqvgzzafzuqrbzzmhxbqjuezwnnzdcyhghhrmzzgbzgqxmjgwfurmwycgemvbvxcvxvesqsgatnvgwvzujmcbrwtqrvmsmvnnbcugxarqeshthfzusfbbzedzqgfmzwqgzzsnxnffgusfdzjsrxfzumwzqrnnrtdnrjgfrwdrqxtgrbrahcndshqmbfwuqrtnhshtgzqamrhbgzzwwqmqyrtzwqfzwvsghzhdtyfebntshqzrnevbbcywc

トレーナー世界ランキング(1〜250位)
zrngzdnqxyxmfmzwxvfqnwwhadfaxnreztburuuzqzrvscvtahzryjmztbgqbsxjcfzrutrwxrnnrzdsucyrsvcscueqvyzbmssbuqtdjzwqhzhbhtmssybhwztvhztztrsscgbsxengqstbmqweqdnzfqztcqdqdjgbrsnrnrrdchmmsfuecjxmftgyqwunbmmmwfuhrznvfdrrfzsjbqxrcgjztxcerfertthrnhhurxjtumwjfxzxyt


ば考集計方法「単一換字変換と文字出現率を組み合わせれば簡単にランキングが作れるのではないだろうか」


ば作

ばPC立上

ば記C#

ば簡単作成

using System;
using System.Collections.Generic;
using System.Linq;

namespace SimpleSubstitutionCipher
{
    class ConvertCharacterList
    {
        //Read Users Input
        static string readText()
        {
            Console.WriteLine("\n--------------------------------\n");
            var originalText = Console.ReadLine();
            Console.WriteLine("\n--------------------------------\n");
            return originalText;
        }

        //Output Console
        static void WriteAllStatistics(Dictionary<char, string> name, Dictionary<char, float> stat)
        {
            //var sort = stat.OrderBy((x) => x.Value);
            var sort = stat.OrderByDescending((x) => x.Value);
            foreach (var st in sort)
                Console.WriteLine($"{name[st.Key]}  \t: {stat[st.Key]}%");
        }

        static void Main(string[] args)
        {
            var Statistics = new Dictionary<char, float>();
            var CharacterList
                = new Dictionary<char, string>()
                {
                    {'q',"Darkrai"},{'w',"Blaziken"},{'e',"Pikachu"},{'r',"Lucario"},{'t',"Gardevoir"},{'y',"Masked"},{'u',"Scizor"},
                    {'a',"Crogunk"},{'s',"Sceptile"},{'d',"Genger"},{'f',"Desidueye"},{'g',"Machamp"},{'h',"Braixen"},{'j',"Empoleon"},
                    {'z',"Mewtwo"},{'x',"Chandelure"},{'c',"Suicune"},{'v',"Weavile"},{'b',"Charizard"},{'n',"Garchomp"},{'m',"Dark M2"},
                };

            //1.Read users input
            var originalText = readText();

            //2.Substitution ratio
            foreach (var ch in CharacterList)
            {
                float ratio = (float)originalText.Count(c => c == ch.Key) / (float)originalText.Length * 100;
                Statistics.Add(ch.Key, ratio);
            }

            //3.Output console
            WriteAllStatistics(CharacterList, Statistics);

            Console.WriteLine("\n--------------------------------\n");
            Console.WriteLine("Statistics Complete!! (Press Any Key)");
            Console.ReadKey();
        }
    }
}

ば試

My job here is done.



ば解説

using System;
using System.Collections.Generic;
using System.Linq;

ばライブラリ宣言
Dictionary故Collections.Generic使用
途中ラムダ式LINQ配列整理故Linq使用



        //Read Users Input
        static string readText()
        {
            Console.WriteLine("\n--------------------------------\n");
            var originalText = Console.ReadLine();
            Console.WriteLine("\n--------------------------------\n");
            return originalText;
        }

ば作成モジュール
コンソール故ユーザー入力orコピペ待



        //Output Console
        static void WriteAllStatistics(Dictionary<char, string> name, Dictionary<char, float> stat)
        {
            //var sort = stat.OrderBy((x) => x.Value);
            var sort = stat.OrderByDescending((x) => x.Value);
            foreach (var st in sort)
                Console.WriteLine($"{name[st.Key]}  \t: {stat[st.Key]}%");
        }

ば再作モ
前半LINQ使用ソート
上米外下米切替、結果昇順。
標準降順。
後半結果出力。



            var Statistics = new Dictionary<char, float>();
            var CharacterList
                = new Dictionary<char, string>()
                {
                    {'q',"Darkrai"},{'w',"Blaziken"},{'e',"Pikachu"},{'r',"Lucario"},{'t',"Gardevoir"},{'y',"Masked"},{'u',"Scizor"},
                    {'a',"Crogunk"},{'s',"Sceptile"},{'d',"Genger"},{'f',"Desidueye"},{'g',"Machamp"},{'h',"Braixen"},{'j',"Empoleon"},
                    {'z',"Mewtwo"},{'x',"Chandelure"},{'c',"Suicune"},{'v',"Weavile"},{'b',"Charizard"},{'n',"Garchomp"},{'m',"Dark M2"},
                };

ば初期化Dictionary
ばCharacterList代入



            //1.Read users input
            var originalText = readText();

            //2.Substitution ratio
            foreach (var ch in CharacterList)
            {
                float ratio = (float)originalText.Count(c => c == ch.Key) / (float)originalText.Length * 100;
                Statistics.Add(ch.Key, ratio);
            }

            //3.Output console
            WriteAllStatistics(CharacterList, Statistics);

ば思キ
1原文string用意
2ば適合及追加Statistics
3コ出力

ば思2重要
ば処理委譲「何個数」
次ば計算個数/全体*100故文字出現率
ば算出後Statistics追加



            Console.WriteLine("\n--------------------------------\n");
            Console.WriteLine("Statistics Complete!! (Press Any Key)");
            Console.ReadKey();

完了コ表示
終了故ば最終入力待

ば非記述例外処理
然非適用文字入力後無視故軽視

ば考桁揃然之良故未変更

ば反省。。。