2016-08-07から1日間の記事一覧

SEND + MORE = MONEY

using System; using System.Collections.Generic; using System.Linq; class Program { static int ToInt(string s, int[] map) { int x = 0; foreach (var c in s) { x = 10 * x + map[c]; if (x == 0 && s.Length > 1) return -1; // leading zero } retu…

文字列の配列を文字のシーケンスに変換する

using System; using System.Linq; class Program { static void Main() { var ss = new[] { "foo", "bar", "baz" }; // 文字列の配列を文字のシーケンスにする var cs = ss.SelectMany(e => e); Console.WriteLine(string.Join(" ", cs)); // => f o o b a …