fork download
  1. /* abc */
  2.  
  3. using System;
  4.  
  5. using System.Collections.Generic;
  6.  
  7. class Cell{
  8.  
  9. public int x;
  10.  
  11. public int y;
  12.  
  13. public int color;
  14.  
  15. }
  16.  
  17. class Game{
  18.  
  19. List<Cell> cells;
  20.  
  21. List<System.Func<Cell,Cell,bool>> predicates;
  22.  
  23. public Game(){
  24.  
  25.  
  26.  
  27. predicates = new List<System.Func<Cell,Cell,bool>>();
  28.  
  29. predicates.Add( delegate(Cell a,Cell b){ return ( b.x - a.x == 0); });
  30.  
  31. predicates.Add( delegate(Cell a,Cell b){ return ( b.y - a.y == 0); });
  32.  
  33. predicates.Add(
  34.  
  35. delegate(Cell a,Cell b){
  36.  
  37. return (
  38.  
  39. ( (b.x - a.x == 0) && (b.y - a.y == 0)) ||
  40.  
  41. (
  42.  
  43. (b.x - a.x != 0 ) &&
  44.  
  45. (
  46.  
  47. (double)(b.y - a.y) / (b.x - a.x) == 1
  48.  
  49. )
  50.  
  51. )
  52.  
  53. );
  54.  
  55. }
  56.  
  57. );
  58.  
  59. predicates.Add(
  60.  
  61. delegate(Cell a,Cell b){
  62.  
  63. return (
  64.  
  65. ( (b.x - a.x == 0) && (b.y - a.y == 0)) ||
  66.  
  67. (
  68.  
  69. (b.x - a.x != 0 ) &&
  70.  
  71. (
  72.  
  73. (double)(b.y - a.y) / (b.x - a.x) == -1
  74.  
  75. )
  76.  
  77. )
  78.  
  79. );
  80.  
  81. }
  82.  
  83. );
  84.  
  85. cells = new List<Cell>();
  86.  
  87. for(int j = 0;j < 5; j++){
  88.  
  89. for(int i = 0;i < 5; i++){
  90.  
  91. Cell cell = new Cell();
  92.  
  93. cell.x = i;
  94.  
  95. cell.y = j;
  96.  
  97. cell.color = 0;
  98.  
  99. cells.Add(cell);
  100.  
  101. }
  102.  
  103. }
  104.  
  105. Test();
  106.  
  107. }
  108.  
  109. public void Test(){
  110.  
  111. List<Evaluator> elist = new List<Evaluator>();
  112.  
  113. cells.ConvertAll(
  114.  
  115. delegate(Cell c1){
  116.  
  117. return predicates.ConvertAll(
  118.  
  119. delegate(System.Func<Cell,Cell,bool> f1){
  120.  
  121. return new Evaluator(c1,f1);
  122.  
  123. }
  124.  
  125. );
  126.  
  127. }
  128.  
  129. ).ForEach(
  130.  
  131. delegate(List<Evaluator> elist1){
  132.  
  133. elist.AddRange(elist1);
  134.  
  135. }
  136.  
  137. );
  138.  
  139. List<List<Cell>> x1 = elist.ConvertAll(
  140.  
  141. delegate(Evaluator e){
  142.  
  143. return cells.FindAll(e.GetResult);
  144.  
  145. }
  146.  
  147. );
  148.  
  149. List<List<Cell>> x2 = new List<List<Cell>>();
  150.  
  151. x1.ForEach(
  152.  
  153. delegate(List<Cell> list1){
  154.  
  155. if(
  156.  
  157. x2.FindAll(
  158.  
  159. delegate(List<Cell> list2){
  160.  
  161. return (list1.Count == list2.Count) &&
  162.  
  163. (list1.TrueForAll(delegate(Cell c){ return list2.Contains(c);}));
  164.  
  165. }
  166.  
  167. ).Count == 0
  168.  
  169. ){
  170.  
  171. x2.Add(list1);
  172.  
  173. }
  174.  
  175. }
  176.  
  177. );
  178.  
  179. x2.ForEach(
  180.  
  181. delegate(List<Cell> testlist){
  182.  
  183. System.Console.WriteLine(
  184.  
  185. String.Concat(
  186.  
  187. testlist.ConvertAll(
  188.  
  189. delegate(Cell c1){
  190.  
  191. return "(" + c1.x.ToString() + "," + c1.y.ToString() + ")";
  192.  
  193. }
  194.  
  195. )
  196.  
  197. )
  198.  
  199. );
  200.  
  201. }
  202.  
  203. );
  204.  
  205. }
  206.  
  207. }
  208.  
  209. class Evaluator{
  210.  
  211. Cell c = null;
  212.  
  213. System.Func<Cell,Cell,bool> f = null;
  214.  
  215. public Evaluator(Cell c1,System.Func<Cell,Cell,bool> f1){
  216.  
  217. c = c1;
  218.  
  219. f = f1;
  220.  
  221. }
  222.  
  223. public bool GetResult (Cell c1){
  224.  
  225. return f(c,c1);
  226.  
  227. }
  228.  
  229. }
  230.  
  231. class HOGE{
  232.  
  233. public static void Main(){
  234.  
  235. Game g = new Game();
  236.  
  237. }
  238.  
  239. }
stdin
Standard input is empty
compilation info
prog.cs(235,38): warning CS0219: The variable `g' is assigned but its value is never used
Compilation succeeded - 1 warning(s)
stdout
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]
System.Collections.Generic.List`1[System.String]