結果はどこかのwikiにのっていると思うので省略。
なお、実は一つ仕様上のプログラムミスがあるのだが気づくだろうか。
ここからは組と、昇順の重複なしの組み合わせでの番号とを相互変換するプログラムである。例えば{1,2,3,4,5}→1と出て、{1,2,3,4,6}→2と出て、{21,22,23,24,25}=53130(=25C5)と出る。
なんか全然整数にならなさそうな式だが、これは単純にΣをばらしただけなので、一応整数値を返す。興味があれば計算してみるとよいが、非常に面倒である。
toID[a_, b_, c_, d_, e_] := -15275 + (231879 a)/20 - (24265 a^2)/
24 + (1057 a^3)/24 - (23 a^4)/24 + a^5/120 + (25897 b)/12 - (
3311 b^2)/24 + (47 b^3)/12 - b^4/24 + (1727 c)/6 - 12 c^2 + c^3/
6 + (49 d)/2 - d^2/2 + e
manipulate1[x_] :=
For[i = 1,
x > 1/120 (-1518000 + 1650244 i - 137880 i^2 + 5755 i^3 - 120 i^4 +
i^5), i++, mat[[1]] = i;
minus[[1]] =
1/120 (-1518000 + 1650244 i - 137880 i^2 + 5755 i^3 - 120 i^4 +
i^5)];
manipulate2[x_] :=
For[i = mat[[1]] + 1,
x - minus[[1]] >
1/24 (-55200 + 58702 i - 3599 i^2 + 98 i^3 - i^4 -
51794 mat[[1]] + 3311 mat[[1]]^2 - 94 mat[[1]]^3 + mat[[1]]^4),
i++, mat[[2]] = i;
minus[[2]] =
1/24 (-55200 + 58702 i - 3599 i^2 + 98 i^3 - i^4 -
51794 mat[[1]] + 3311 mat[[1]]^2 - 94 mat[[1]]^3 + mat[[1]]^4)];
manipulate3[x_] :=
For[i = mat[[2]] + 1,
x - minus[[1]] - minus[[2]] >
1/6 (-1800 + 1874 i - 75 i^2 + i^3 - 1727 mat[[2]] +
72 mat[[2]]^2 - mat[[2]]^3), i++, mat[[3]] = i;
minus[[3]] =
1/6 (-1800 + 1874 i - 75 i^2 + i^3 - 1727 mat[[2]] +
72 mat[[2]]^2 - mat[[2]]^3)];
manipulate4[x_] :=
For[i = mat[[3]] + 1,
x - minus[[1]] - minus[[2]] - minus[[3]] >
1/2 (-50 + 51 i - i^2 - 49 mat[[3]] + mat[[3]]^2), i++,
mat[[4]] = i;
minus[[4]] = 1/2 (-50 + 51 i - i^2 - 49 mat[[3]] + mat[[3]]^2)];
manipulate5[x_] :=
For[i = mat[[4]] + 1,
x - minus[[1]] - minus[[2]] - minus[[3]] - minus[[4]] > -1 + i -
mat[[4]], i++, mat[[5]] = i];
freepat[x_] :=
Which[x == 1, free = {1, 11, 13, 19, 23}, x == 2,
free = {1, 9, 11, 13, 19}, x == 3, free = {1, 13, 19, 21, 23},
x == 4, free = {1, 11, 13, 19, 24}, x == 5,
free = {1, 9, 11, 13, 23}, x == 6, free = {2, 11, 13, 19, 23},
x == 7, free = {1, 9, 11, 13, 24}, x == 8,
free = {1, 11, 13, 20, 23}];
rot[list_] :=
For[r = 1, r <= 5, r++,
Which[list[[r]] == 7, newlist[[r]] = 12, list[[r]] == 8,
newlist[[r]] = 7, list[[r]] == 9, newlist[[r]] = 8,
list[[r]] == 12, newlist[[r]] = 17, list[[r]] == 14,
newlist[[r]] = 9,
list[[r]] == 17, newlist[[r]] = 18, list[[r]] == 18,
newlist[[r]] = 19, list[[r]] == 19, newlist[[r]] = 14]];
ringo[x_] :=
Which[x == 1, {1, 2, 3, 4, 5}, x == 2, {6, 7, 8, 9, 10},
x == 3, {11, 12, 13, 14, 15}, x == 4, {16, 17, 18, 19, 20},
x == 5, {21, 22, 23, 24, 25}, x == 6, {1, 6, 11, 16, 21},
x == 7, {2, 7, 12, 17, 22}, x == 8, {3, 8, 13, 18, 23},
x == 9, {4, 9, 14, 19, 24}, x == 10, {5, 10, 15, 20, 25},
x == 11, {1, 7, 13, 19, 25}, x == 12, {5, 9, 13, 17, 21}];
rest3 = {0, 0, 0}; minusrest3 = {0, 0, 0};
rest31[x_] :=
For[i = 1, x > 1/6 (-1140 + 1199 i - 60 i^2 + i^3), i++,
rest3[[1]] = i;
minusrest3[[1]] = 1/6 (-1140 + 1199 i - 60 i^2 + i^3)];
rest32[x_] :=
For[i = rest3[[1]] + 1,
x - minusrest3[[1]] >
1/2 (-40 + 41 i - i^2 - 39 rest3[[1]] + rest3[[1]]^2), i++,
rest3[[2]] = i;
minusrest3[[2]] =
1/2 (-40 + 41 i - i^2 - 39 rest3[[1]] + rest3[[1]]^2)];
rest33[x_] :=
For[i = rest3[[2]] + 1,
x - minusrest3[[1]] - minusrest3[[2]] > i - rest3[[2]] - 1, i++,
rest3[[3]] = i]
ここから実行部。
mat = {0, 0, 0, 0, 0}; pat = 7; minus = {0, 0, 0, 0, 0}; mass =
Table[0, 25]; hit = Table[0, 5]; free = Table[0, 5]; For[n = 33751,
n <= 53130, n++, newlist = Table[0, 5]; manipulate1[n];
manipulate2[n]; manipulate3[n]; manipulate4[n]; manipulate5[n];
For[k = 1, k <= 5, k++, hit[[k]] = mat[[k]]]; freepat[pat];
For[pattern = 1, pattern <= 8, pattern++, bairitu = 1; newlist = hit;
Which[pattern == 1, newlist = hit, pattern == 2, rot[hit],
pattern == 3, rot[hit]; rot[newlist], pattern == 4, rot[hit];
rot[newlist]; rot[newlist], pattern == 5, rot[hit]; rot[newlist];
rot[newlist]; rot[newlist], pattern == 6, rot[hit]; rot[newlist];
rot[newlist]; rot[newlist];
rot[newlist], pattern == 7, rot[hit]; rot[newlist]; rot[newlist];
rot[newlist]; rot[newlist]; rot[newlist], pattern == 8, rot[hit];
rot[newlist]; rot[newlist]; rot[newlist]; rot[newlist];
rot[newlist]; rot[newlist]]; totalodds = 0; skip = 0;
newlist = Sort[newlist];
b = newlist;
If[toID[newlist[[1]], newlist[[2]], newlist[[3]], newlist[[4]],
newlist[[5]]] <
toID[hit[[1]], hit[[2]], hit[[3]], hit[[4]], hit[[5]]],
result[[n]] =
result[[toID[newlist[[1]], newlist[[2]], newlist[[3]],
newlist[[4]], newlist[[5]]]]];
For[c = 1, c <= 9 - pattern, c++, taihi = result[[n, 1]];
result[[n, 1]] = result[[n, 2]]; result[[n, 2]] = result[[n, 3]];
result[[n, 3]] = result[[n, 4]]; result[[n, 4]] = result[[n, 5]];
result[[n, 5]] = result[[n, 6]]; result[[n, 6]] = result[[n, 7]];
result[[n, 7]] = result[[n, 8]]; result[[n, 8]] = taihi];
skip = 1; pattern = 8];
If[toID[newlist[[1]], newlist[[2]], newlist[[3]], newlist[[4]],
newlist[[5]]] ==
toID[hit[[1]], hit[[2]], hit[[3]], hit[[4]], hit[[5]]] &&
pattern == 2, skip = 1; pattern = 8;
result[[n, 2]] = result[[n, 1]];
result[[n, 3]] = result[[n, 1]];
result[[n, 4]] = result[[n, 1]]; result[[n, 5]] = result[[n, 1]];
result[[n, 6]] = result[[n, 1]]; result[[n, 7]] = result[[n, 1]];
result[[n, 8]] = result[[n, 1]]];
If[skip == 0,
For[z = 1, z <= 1140, z++, newlist = b; bairitu = 1; rest31[z];
rest32[z]; rest33[z];
A = Table[i, {i, 25}];
A = Delete[
A, {{newlist[[1]]}, {newlist[[2]]}, {newlist[[3]]}, {newlist[[
4]]}, {newlist[[5]]}}];
newlist =
Append[Append[Append[newlist, A[[rest3[[1]]]]], A[[rest3[[2]]]]],
A[[rest3[[3]]]]];
count = Count[newlist, 13]; freepat[pat];
If[count == 1,
free = Append[Append[Append[Append[free, 8], 12], 14], 18]];
mass = Table[0, 25];
For[p = 1, p <= 25, p++,
Which[MemberQ[free, p] == True && MemberQ[newlist, p] == True,
mass[[p]] = 1; bairitu += 1,
MemberQ[free, p] == True || MemberQ[newlist, p] == True,
mass[[p]] = 1]];
bingo = 0;
If[mass[[1]] == 1 && mass[[2]] == 1 && mass[[3]] == 1 &&
mass[[4]] == 1 && mass[[5]] == 1, bingo += 1];
If[mass[[6]] == 1 && mass[[7]] == 1 && mass[[8]] == 1 &&
mass[[9]] == 1 && mass[[10]] == 1, bingo += 1];
If[mass[[11]] == 1 && mass[[12]] == 1 && mass[[13]] == 1 &&
mass[[14]] == 1 && mass[[15]] == 1, bingo += 1];
If[mass[[16]] == 1 && mass[[17]] == 1 && mass[[18]] == 1 &&
mass[[19]] == 1 && mass[[20]] == 1, bingo += 1];
If[mass[[21]] == 1 && mass[[22]] == 1 && mass[[23]] == 1 &&
mass[[24]] == 1 && mass[[25]] == 1, bingo += 1];
If[mass[[1]] == 1 && mass[[6]] == 1 && mass[[11]] == 1 &&
mass[[16]] == 1 && mass[[21]] == 1, bingo += 1];
If[mass[[2]] == 1 && mass[[7]] == 1 && mass[[12]] == 1 &&
mass[[17]] == 1 && mass[[22]] == 1, bingo += 1];
If[mass[[3]] == 1 && mass[[8]] == 1 && mass[[13]] == 1 &&
mass[[18]] == 1 && mass[[23]] == 1, bingo += 1];
If[mass[[4]] == 1 && mass[[9]] == 1 && mass[[14]] == 1 &&
mass[[19]] == 1 && mass[[24]] == 1, bingo += 1];
If[mass[[5]] == 1 && mass[[10]] == 1 && mass[[15]] == 1 &&
mass[[20]] == 1 && mass[[25]] == 1, bingo += 1];
If[mass[[1]] == 1 && mass[[7]] == 1 && mass[[13]] == 1 &&
mass[[19]] == 1 && mass[[25]] == 1, bingo += 1];
If[mass[[5]] == 1 && mass[[9]] == 1 && mass[[13]] == 1 &&
mass[[17]] == 1 && mass[[21]] == 1, bingo += 1];
odds = 0;
Which[bingo == 0, odds = 0, bingo == 1, odds = 0.5, bingo == 2,
odds = 2.0, bingo == 3, odds = 10.0, bingo == 4, odds = 60.0];
totalodds += odds*bairitu/1140;
]; result[[n, pattern]] = totalodds]
]; Print[{n, result[[n]]}]]
誤り探しの答えは
…Which[MemberQ[free, p] == True && MemberQ[newlist, p] == True && p!=13,
mass[[p]] = 1; bairitu += 1,…の部分で、これだと中心部分にHITした場合、もともとFREEかつHIT扱いとなるが本家ではそのマスのみはHIT扱いと重ねてもオッズアップにならない。すなわち、赤色の「ただし中心(13マス目)は除く」を加える必要があった。