Skip to content

Instantly share code, notes, and snippets.

@jz5

jz5/Chars.cs

Last active Apr 12, 2020
Embed
What would you like to do?
static void Main(string[] args)
{
var lines = File.ReadAllLines(@"ナンバープレート一覧.csv", Encoding.UTF8).ToList();
var places = lines.Skip(1).Select(x => x.Split(',')[2]);
var chars = new List<char>();
var charHashSet = new HashSet<char>();
foreach (var name in places)
{
chars.AddRange(name.ToCharArray());
foreach (var c in name)
{
if (charHashSet.Contains(c))
continue;
charHashSet.Add(c);
}
}
File.WriteAllText("chars.txt", string.Join("", charHashSet.ToList().OrderBy(x => x)), Encoding.UTF8);
File.WriteAllText("chars_rank.txt", string.Join("\r\n", chars.GroupBy(x => x).OrderByDescending(y => y.Count()).ThenBy(y => y.Key).Select(y => $"{y.Key}\t{y.Count()}")), Encoding.UTF8);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment