SiroKuro #4731(2007/12/10 18:17 GMT) [ C# ] Rating2/2=1.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
using System; using System.Collections.Generic; using IronPython; using IronPython.Hosting; using IronPython.Runtime; using IronPython.Runtime.Calls; class Program { static void Main() { PythonEngine python = new PythonEngine(); EngineModule module = python.CreateModule(); Dictionary<string, object> locals = new Dictionary<string, object>(); int count = 0; locals["komachi"] = new CallTarget2(delegate(object obj, object obj2) { if (obj2.Equals(100.0)) { count++; Console.WriteLine(obj + " = " + obj2); } return null; }); DateTime before = DateTime.Now; foreach (string code in GenPythonCode()) { python.Execute(code, module, locals); } Console.WriteLine("time: {0}", DateTime.Now - before); Console.WriteLine("total: {0}", count); } static IEnumerable<string> GenPythonCode() { string[] ops = { "", ".0+", ".0-", ".0*", ".0/" }; for (int i = 0; i < Math.Pow(ops.Length, 8); i++) { string code = "1"; int j = i; foreach (char num in "23456789") { code += ops[j % ops.Length] + num; j /= ops.Length; } yield return string.Format("komachi(\"{0}\", {0})", code + ".0"); } } }
Rating2/2=1.00-0+
[ reply ]
SiroKuro
#4731()
[
C#
]
Rating2/2=1.00
Rating2/2=1.00-0+
[ reply ]