|
紫の薔薇の人 |
|
using System;
using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sansu995 { /* A−J I−H / \ / \ B X−Y G \ / \ / C−D E−F */ public class Figure995 { public int a; public int b; public int c; public int d; public int e; public int f; public int g; public int h; public int i; public int j; public Figure995(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { this.a = a; this.b = b; this.c = c; this.d = d; this.e = e; this.f = f; this.g = g; this.h = h; this.i = i; this.j = j; } public Figure995(): this(0, 0, 0, 0, 0, 0, 0, 0, 0, 0) { } public Figure995 H(Figure995 x) { return new Figure995(x.h,x.g,x.f,x.e,x.d,x.c,x.b,x.a,x.j,x.i); } public Figure995 V(Figure995 x) { return new Figure995(x.c, x.b, x.a, x.j, x.i, x.h, x.g, x.f, x.e, x.d); } public Figure995 R(Figure995 x) { return new Figure995(x.f, x.g, x.h, x.i, x.j, x.a, x.b, x.c, x.d, x.e); } public string str(Figure995 x) { return string.Format("({0} {1} {2} {3} {4} {5} {6} {7} {8} {9})", x.a, x.b, x.c, x.d, x.e, x.f, x.g, x.h, x.i, x.j); } public override String ToString() { return str(this); } } class Figure995EqualityComparer : IEqualityComparer<Figure995> { public bool Equals(Figure995 b1, Figure995 b2) { if (b2 == null && b1 == null) return true; else if (b1 == null | b2 == null) return false; else if ( b1.a == b2.a && b1.b == b2.b && b1.c == b2.c && b1.d == b2.d && b1.e == b2.e && b1.f == b2.f && b1.g == b2.g && b1.h == b2.h && b1.i == b2.i && b1.j == b2.j ) return true; else return false; } public int GetHashCode(Figure995 bx) { int hCode = bx.a << 9 + bx.b << 8 + bx.c << 7 + bx.d << 6 + bx.e << 5 + bx.f << 4 + bx.g << 3 + bx.h << 2 + bx.i << 1 + bx.j; return hCode; } } class Program { static void Main(string[] args) { Figure995EqualityComparer figure995EqC = new Figure995EqualityComparer(); // HashSetクラスによるFigure995テーブル HashSet<Figure995> hsTable = new HashSet<Figure995>(figure995EqC); for (int a = 0; a < 2; a++) for (int b = 0; b < 2; b++) for (int c = 0; c < 2; c++) for (int d = 0; d < 2; d++) for (int e = 0; e < 2; e++) for (int f = 0; f < 2; f++) for (int g = 0; g < 2; g++) for (int h = 0; h < 2; h++) for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) { Figure995 pattern0 = new Figure995(a, b, c, d, e, f, g, h, i, j); if (hsTable.Contains(pattern0)) { continue; } Figure995 pattern1 = pattern0.H(pattern0); if (hsTable.Contains(pattern1)) { continue; } pattern1 = pattern0.V(pattern0); if (hsTable.Contains(pattern1)) { continue; } pattern1 = pattern0.R(pattern0); if (hsTable.Contains(pattern1)) { continue; } // Figure995を追加。未登録なら表示 if (hsTable.Add(pattern0)) { Console.WriteLine("{0:D4}:{1}", hsTable.Count, pattern0.ToString()); } } Console.WriteLine("Total pattern number: {0:D4}", hsTable.Count); } } } |
|
11月5日(土) 0:55:45
45490 |