質問編集履歴
2
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -77,3 +77,37 @@
|
|
77
77
|
-1+2-3+4+5+6+78+9=100
|
78
78
|
|
79
79
|
```
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
ちょっと変更
|
84
|
+
|
85
|
+
- Compute使わない
|
86
|
+
|
87
|
+
- 1..9の配列使わない
|
88
|
+
|
89
|
+
```lang-c#
|
90
|
+
|
91
|
+
static void Main(string[] args)
|
92
|
+
|
93
|
+
{
|
94
|
+
|
95
|
+
Enumerable.Repeat(new[] { " ", "-", "+" }, 9).Aggregate(Enumerable.Repeat("", 1)
|
96
|
+
|
97
|
+
, (a, ca) => from s in a from c in ca select s + c)
|
98
|
+
|
99
|
+
.Select(p => string.Concat(p.Select((x, i) => "" + x + (i + 1))).Replace(" ", ""))
|
100
|
+
|
101
|
+
.TakeWhile(x => !x.StartsWith("+"))
|
102
|
+
|
103
|
+
.Select(x => x.Replace("-", "@-").Replace("+", "@+").Split('@').Where(y => y != ""))
|
104
|
+
|
105
|
+
.Where(x => x.Select(int.Parse).Sum() == 100)
|
106
|
+
|
107
|
+
.ToList().ForEach(x => Console.WriteLine(string.Concat(x) + "=100"));
|
108
|
+
|
109
|
+
Console.ReadKey();
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
```
|
1
出力結果追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -45,3 +45,35 @@
|
|
45
45
|
}
|
46
46
|
|
47
47
|
```
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
出力結果
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
123-45-67+89=100
|
56
|
+
|
57
|
+
123-4-5-6-7+8-9=100
|
58
|
+
|
59
|
+
123+45-67+8-9=100
|
60
|
+
|
61
|
+
123+4-5+67-89=100
|
62
|
+
|
63
|
+
12-3-4+5-6+7+89=100
|
64
|
+
|
65
|
+
12+3-4+5+67+8+9=100
|
66
|
+
|
67
|
+
12+3+4+5-6-7+89=100
|
68
|
+
|
69
|
+
1+23-4+56+7+8+9=100
|
70
|
+
|
71
|
+
1+23-4+5+6+78-9=100
|
72
|
+
|
73
|
+
1+2+34-5+67-8+9=100
|
74
|
+
|
75
|
+
1+2+3-4+5+6+78+9=100
|
76
|
+
|
77
|
+
-1+2-3+4+5+6+78+9=100
|
78
|
+
|
79
|
+
```
|