昔書いたプログラムの結果はもう少し色々出て来た気がしたので、手牌の同一牌制限を3枚から4枚にしてみたところ、

C:\ruby>mentin13a
"0,1,1,4,1,1,1,1,3"
"0,1,1,4,1,4,1,1,0"
"0,1,4,2,1,1,1,3,0"
"0,3,1,1,1,1,4,1,1"
"0,3,1,1,1,2,4,1,0"
"1,1,4,1,1,1,1,3,0"
"3,1,1,1,1,1,1,1,3"
"3,1,1,1,1,4,1,1,0"
93600

となった。昔見た結果はこれだったのかもしれないな。
これだと厳密には9面待ちにはならないけど。
とりあえずこれでメンチン9面待ちプロジェクトは終了。
折角頭の片隅から昔学んだプログラミングを引っ張り出して来たので、引き続き色々ゲームがらみでプログラム組んで行こうと思う。

今回のコードは以下の通り

# Your code here!
Prime=[1,2,3,5,7,11,13,17,19,23]
t=0
for a in 0..4
for b in 0..4
for c in 0..4
#if a+b+c<1 then;emin=1;else;emin=0;end
if a+b+c>9 then;dmax=13-a-b-c;else;dmax=4;end

for d in 0..dmax
#if a+b+c+d<1 then;emin=1;else;emin=0;end
if a+b+c+d>9 then;emax=13-a-b-c-d;else;emax=4;end

for e in 0..emax
if a+b+c+d+e<1 then;fmin=1-a-b-c-d-e;else;fmin=0;end
if a+b+c+d+e>9 then;fmax=13-a-b-c-d-e;else;fmax=4;end

for f in fmin..fmax
if a+b+c+d+e+f<5 then;gmin=5-a-b-c-d-e-f;else;gmin=0;end
if a+b+c+d+e+f>9 then;gmax=13-a-b-c-d-e-f;else;gmax=4;end

for g in gmin..gmax
if a+b+c+d+e+f+g<9 then;hmin=9-a-b-c-d-e-f-g;else;hmin=0;end
if a+b+c+d+e+f+g>9 then;hmax=13-a-b-c-d-e-f-g;else;hmax=4;end

for h in hmin..hmax
i=13-a-b-c-d-e-f-g-h
t+=1

machi=1

for tumo in 1..9
agari=0

for atama in 1..9
tehai=2**a*3**b*5**c*7**d*11**e*13**f*17**g*19**h*23**i*Prime[tumo]
#if t%1000==0 then;p "#{t},#{tehai}";end

if tehai%Prime[atama]**2==0 then
tehai=tehai/Prime[atama]**2
if tehai%8==0 then;tehai=tehai/8;end
if tehai%30==0 then;tehai=tehai/30;end
if tehai%30==0 then;tehai=tehai/30;end
if tehai%27==0 then;tehai=tehai/27;end
if tehai%105==0 then;tehai=tehai/105;end
if tehai%105==0 then;tehai=tehai/105;end
if tehai%125==0 then;tehai=tehai/125;end
if tehai%385==0 then;tehai=tehai/385;end
if tehai%385==0 then;tehai=tehai/385;end
if tehai%343==0 then;tehai=tehai/343;end
if tehai%1001==0 then;tehai=tehai/1001;end
if tehai%1001==0 then;tehai=tehai/1001;end
if tehai%1331==0 then;tehai=tehai/1331;end
if tehai%2431==0 then;tehai=tehai/2431;end
if tehai%2431==0 then;tehai=tehai/2431;end
if tehai%2197==0 then;tehai=tehai/2197;end
if tehai%4199==0 then;tehai=tehai/4199;end
if tehai%4199==0 then;tehai=tehai/4199;end
if tehai%4913==0 then;tehai=tehai/4913;end
if tehai%7429==0 then;tehai=tehai/7429;end
if tehai%7429==0 then;tehai=tehai/7429;end
if tehai%6859==0 then;tehai=tehai/6859;end
if tehai%12167==0 then;tehai=tehai/12167;end
if tehai==1 then;agari=1;else;agari=0;end
end

if agari==1 then;break;end
end #for atama

if agari==1 then;machi=machi*Prime[tumo];end
end #for tumo

if machi==223092870 then;p "#{a},#{b},#{c},#{d},#{e},#{f},#{g},#{h},#{i}";end

end
end
end
end
end
end
end
end
p t

上手く行かなかった原因が、コードを紙に印刷して整理したら判明した。
原因は頭を落としていなかったこと。つまり
>tehai=tehai/Prime[atama]**2
の一行を入れ忘れていたこと。

オンラインだとタイムアウトしてしまったのでローカルで動かした結果、

C:\ruby>mentin13.rb
"3,1,1,1,1,1,1,1,3"
30276

つまり13面待ちになるのは純正九蓮宝燈の形のみ。
伊達にダブル役満じゃないね。

完成コードは以下の通り。本当はアガリ判定に七対子も入れないといけないんだけど今回は結果に影響が無いので割愛した。

# Your code here!
Prime=[1,2,3,5,7,11,13,17,19,23]
t=0
for a in 0..3
for b in 0..3
for c in 0..3
for d in 0..3
if a+b+c+d<1 then;emin=1;else;emin=0;end
if a+b+c+d>10 then;emax=13-a-b-c-d;else;emax=3;end

for e in emin..emax
if a+b+c+d+e<4 then;fmin=4-a-b-c-d-e;else;fmin=0;end
if a+b+c+d+e>10 then;fmax=13-a-b-c-d-e;else;fmax=3;end

for f in fmin..fmax
if a+b+c+d+e+f<7 then;gmin=7-a-b-c-d-e-f;else;gmin=0;end
if a+b+c+d+e+f>10 then;gmax=13-a-b-c-d-e-f;else;gmax=3;end

for g in gmin..gmax
if a+b+c+d+e+f+g<10 then;hmin=10-a-b-c-d-e-f-g;else;hmin=0;end
if a+b+c+d+e+f+g>10 then;hmax=13-a-b-c-d-e-f-g;else;hmax=3;end

for h in hmin..hmax
i=13-a-b-c-d-e-f-g-h
t+=1

machi=1

for tumo in 1..9
agari=0

for atama in 1..9
tehai=2**a*3**b*5**c*7**d*11**e*13**f*17**g*19**h*23**i*Prime[tumo]
#if t%1000==0 then;p "#{t},#{tehai}";end

if tehai%Prime[atama]**2==0 then
tehai=tehai/Prime[atama]**2
if tehai%8==0 then;tehai=tehai/8;end
if tehai%30==0 then;tehai=tehai/30;end
if tehai%30==0 then;tehai=tehai/30;end
if tehai%27==0 then;tehai=tehai/27;end
if tehai%105==0 then;tehai=tehai/105;end
if tehai%105==0 then;tehai=tehai/105;end
if tehai%125==0 then;tehai=tehai/125;end
if tehai%385==0 then;tehai=tehai/385;end
if tehai%385==0 then;tehai=tehai/385;end
if tehai%343==0 then;tehai=tehai/343;end
if tehai%1001==0 then;tehai=tehai/1001;end
if tehai%1001==0 then;tehai=tehai/1001;end
if tehai%1331==0 then;tehai=tehai/1331;end
if tehai%2431==0 then;tehai=tehai/2431;end
if tehai%2431==0 then;tehai=tehai/2431;end
if tehai%2197==0 then;tehai=tehai/2197;end
if tehai%4199==0 then;tehai=tehai/4199;end
if tehai%4199==0 then;tehai=tehai/4199;end
if tehai%4913==0 then;tehai=tehai/4913;end
if tehai%7429==0 then;tehai=tehai/7429;end
if tehai%7429==0 then;tehai=tehai/7429;end
if tehai%6859==0 then;tehai=tehai/6859;end
if tehai%12167==0 then;tehai=tehai/12167;end
if tehai==1 then;agari=1;else;agari=0;end
end

if agari==1 then;break;end
end #for atama

if agari==1 then;machi=machi*Prime[tumo];end
end #for tumo

if machi==223092870 then;p "#{a},#{b},#{c},#{d},#{e},#{f},#{g},#{h},#{i}";end

end
end
end
end
end
end
end
end
p t

麻雀でメンチン9面待ちの形がいくつあるのかを調べるためのプログラムを書いている。
10年くらい前に書いたことがあるのだがコードが見つからないので再びチャレンジ。
しかし上手くいかないな・・・なんでだろう。

コード
https://paiza.io/projects/V64nivxXXf9Bvb2d9G96pg?language=ruby

(その2に続く)

久々にプログラムを組んで調べてみた。
6-7-8が最もドボン率が低いのね。直感的には、もっと広く散っているかと思ってた。

tcasesdiceAliveDead
1311192"6,7,8"92.0%8.0%
1161185"5,7,8"91.4%8.6%
1321185"6,7,9"91.4%8.6%
901181"4,6,8"91.1%8.9%
1371181"6,8,10"91.1%8.9%
951170"4,7,8"90.3%9.7%
1331170"6,7,10"90.3%9.7%
1111160"5,6,8"89.5%10.5%
1361160"6,8,9"89.5%10.5%
671157"3,7,8"89.3%10.7%
961157"4,7,9"89.3%10.7%
1181157"5,7,10"89.3%10.7%
1341157"6,7,11"89.3%10.7%
311154"2,7,8"89.0%11.0%
1351154"6,7,12"89.0%11.0%
1101149"5,6,7"88.7%11.3%
1461149"7,8,9"88.7%11.3%
891148"4,6,7"88.6%11.4%
1471148"7,8,10"88.6%11.4%
261145"2,6,8"88.3%11.7%
921145"4,6,10"88.3%11.7%
1011145"4,8,10"88.3%11.7%
1391145"6,8,12"88.3%11.7%
971136"4,7,10"87.7%12.3%
1121123"5,6,9"86.7%13.3%
1211123"5,8,9"86.7%13.3%
611121"3,6,7"86.5%13.5%
1481121"7,8,11"86.5%13.5%
251120"2,6,7"86.4%13.6%
911120"4,6,9"86.4%13.6%
1221120"5,8,10"86.4%13.6%
1491120"7,8,12"86.4%13.6%
1001118"4,8,9"86.3%13.7%
1131118"5,6,10"86.3%13.7%
621106"3,6,8"85.3%14.7%
1171106"5,7,9"85.3%14.7%
1381106"6,8,11"85.3%14.7%
831099"4,5,7"84.8%15.2%
1501099"7,9,10"84.8%15.2%
841096"4,5,8"84.6%15.4%
1401096"6,9,10"84.6%15.4%
681092"3,7,9"84.3%15.7%
1191092"5,7,11"84.3%15.7%
321083"2,7,9"83.6%16.4%
691083"3,7,10"83.6%16.4%
721083"3,8,9"83.6%16.4%
981083"4,7,11"83.6%16.4%
1141083"5,6,11"83.6%16.4%
1201083"5,7,12"83.6%16.4%
271080"2,6,9"83.3%16.7%
331080"2,7,10"83.3%16.7%
731080"3,8,10"83.3%16.7%
931080"4,6,11"83.3%16.7%
991080"4,7,12"83.3%16.7%
1241080"5,8,12"83.3%16.7%
201074"2,5,8"82.9%17.1%
1421074"6,9,12"82.9%17.1%
631071"3,6,9"82.6%17.4%
1231071"5,8,11"82.6%17.4%
361066"2,8,9"82.3%17.7%
641066"3,6,10"82.3%17.7%
861066"4,5,10"82.3%17.7%
1021066"4,8,11"82.3%17.7%
1041066"4,9,10"82.3%17.7%
1151066"5,6,12"82.3%17.7%
131057"2,4,8"81.6%18.4%
371057"2,8,10"81.6%18.4%
941057"4,6,12"81.6%18.4%
1441057"6,10,12"81.6%18.4%
281051"2,6,10"81.1%18.9%
1031051"4,8,12"81.1%18.9%
191049"2,5,7"80.9%19.1%
1521049"7,9,12"80.9%19.1%
561047"3,5,8"80.8%19.2%
1411047"6,9,11"80.8%19.2%
121046"2,4,7"80.7%19.3%
1541046"7,10,12"80.7%19.3%
851035"4,5,9"79.9%20.1%
1251035"5,9,10"79.9%20.1%
491032"3,4,8"79.6%20.4%
821032"4,5,6"79.6%20.4%
1431032"6,10,11"79.6%20.4%
1561032"8,9,10"79.6%20.4%
481025"3,4,7"79.1%20.9%
1531025"7,10,11"79.1%20.9%
551020"3,5,7"78.7%21.3%
1511020"7,9,11"78.7%21.3%
351012"2,7,12"78.1%21.9%
341009"2,7,11"77.9%22.1%
501009"3,4,9"77.9%22.1%
711009"3,7,12"77.9%22.1%
761009"3,9,10"77.9%22.1%
871009"4,5,11"77.9%22.1%
1281009"5,10,11"77.9%22.1%
571006"3,5,9"77.6%22.4%
701006"3,7,11"77.6%22.4%
1261006"5,9,11"77.6%22.4%
54999"3,5,6"77.1%22.9%
157999"8,9,11"77.1%22.9%
18998"2,5,6"77.0%23.0%
158998"8,9,12"77.0%23.0%
21985"2,5,9"76.0%24.0%
127985"5,9,12"76.0%24.0%
11983"2,4,6"75.8%24.2%
58983"3,5,10"75.8%24.2%
65983"3,6,11"75.8%24.2%
74983"3,8,11"75.8%24.2%
105983"4,9,11"75.8%24.2%
160983"8,10,12"75.8%24.2%
5980"2,3,8"75.6%24.4%
14980"2,4,9"75.6%24.4%
22980"2,5,10"75.6%24.4%
29980"2,6,11"75.6%24.4%
51980"3,4,10"75.6%24.4%
75980"3,8,12"75.6%24.4%
106980"4,9,12"75.6%24.4%
107980"4,10,11"75.6%24.4%
129980"5,10,12"75.6%24.4%
145980"6,11,12"75.6%24.4%
4975"2,3,7"75.2%24.8%
155975"7,11,12"75.2%24.8%
47962"3,4,6"74.2%25.8%
159962"8,10,11"74.2%25.8%
15957"2,4,10"73.8%26.2%
30957"2,6,12"73.8%26.2%
39957"2,8,12"73.8%26.2%
108957"4,10,12"73.8%26.2%
38954"2,8,11"73.6%26.4%
66954"3,6,12"73.6%26.4%
6923"2,3,9"71.2%28.8%
23923"2,5,11"71.2%28.8%
78923"3,9,12"71.2%28.8%
130923"5,11,12"71.2%28.8%
40920"2,9,10"71.0%29.0%
59920"3,5,11"71.0%29.0%
77920"3,9,11"71.0%29.0%
88920"4,5,12"71.0%29.0%
3886"2,3,6"68.4%31.6%
161886"8,11,12"68.4%31.6%
46867"3,4,5"66.9%33.1%
162867"9,10,11"66.9%33.1%
10852"2,4,5"65.7%34.3%
163852"9,10,12"65.7%34.3%
52851"3,4,11"65.7%34.3%
79851"3,10,11"65.7%34.3%
41825"2,9,11"63.7%36.3%
60825"3,5,12"63.7%36.3%
7822"2,3,10"63.4%36.6%
16822"2,4,11"63.4%36.6%
24822"2,5,12"63.4%36.6%
42822"2,9,12"63.4%36.6%
80822"3,10,12"63.4%36.6%
109822"4,11,12"63.4%36.6%
2757"2,3,5"58.4%41.6%
164757"9,11,12"58.4%41.6%
43750"2,10,11"57.9%42.1%
53750"3,4,12"57.9%42.1%
17715"2,4,12"55.2%44.8%
44715"2,10,12"55.2%44.8%
8681"2,3,11"52.5%47.5%
81681"3,11,12"52.5%47.5%
1676"2,3,4"52.2%47.8%
165676"10,11,12"52.2%47.8%
9568"2,3,12"43.8%56.2%
45568"2,11,12"43.8%56.2%

※コード

Prime=[1,1,2,3,5,7,11,13,17,19,23,29,31]
Kai=[0]
for t in 0..164
Kai[t]=0
end
seki=0

for a in 1..6
for b in 1..6
for c in 1..6
for d in 1..6

seki=Prime[a+b]*Prime[a+c]*Prime[a+d]*Prime[b+c]*Prime[b+d]*Prime[c+d]

t=0
for x in 2..10
for y in x+1..11
for z in y+1..12
if seki%Prime[x]*seki%Prime[y]*seki%Prime[z]==0 then
Kai[t]+=1
end
t+=1
end
end
end

end
end
end
end

p Kai

※実行

https://paiza.io/en/projects/new?language=ruby

< 2024年01>
S M T W T F S
  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      
QRコード
QRCODE
インフォメーション
長野県・信州ブログコミュニティサイトナガブロ
ログイン

ホームページ制作 長野市 松本市-Web8

アクセスカウンタ
読者登録
メールアドレスを入力して登録する事で、このブログの新着エントリーをメールでお届けいたします。解除は→こちら
現在の読者数 0人
プロフィール
nishiken