Hier der c# Programmcode:
using System;
namespace Würfel
{
class Program
{
private static decimal _anz, _sum;
static void Main()
{
var start = DateTime.Now;
//Schnitt12();
Schnitt6Aus9();
var end = DateTime.Now;
Console.WriteLine("Dauer: " + (end - start));
Console.WriteLine(_sum + " / " + _anz + " = " + _sum / _anz);
Console.WriteLine(_sum / _anz / 6);
Console.ReadLine();
}
static void Schnitt12()
{
for (var st = 0; ++st <= 100; )
{
var hSt = (st << 1) - 1;
var gs = 0;
var stGs = st;
while (++gs <= 100)
{
var hGsSt = ((gs << 1) - 1) * hSt;
var stGsGw = ++stGs;
var gw = 49 - stGsGw;
if (gw <= 0) gw = 0;
else stGsGw += gw;
while (++gw <= 100)
{
var hGwGsSt = ((gw << 1) - 1) * hGsSt;
var stGsGwKo = ++stGsGw;
var ko = 149 - stGsGwKo;
if (ko <= 0) ko = 0;
else stGsGwKo += ko;
while (++ko <= 100)
{
var hKoGwGsSt = ((ko << 1) - 1) * hGwGsSt;
var stGsGwKoIn = ++stGsGwKo;
var i = 249 - stGsGwKoIn;
if (i <= 0) i = 0;
else stGsGwKoIn += i;
while (++i <= 100)
{
var zAnz = 0L;
var zSum = 0L;
var zt = Math.Max(0, 349 - ++stGsGwKoIn);
while (++zt <= 100)
{
var hZtInKoGwGsSt = ((zt << 1) - 1) * ((i << 1) - 1) * (long)hKoGwGsSt;
zAnz += hZtInKoGwGsSt;
zSum += hZtInKoGwGsSt * (stGsGwKoIn + zt);
}
_anz += zAnz;
_sum += zSum;
}
}
}
}
}
}
private const int StGleichGs = 1;
private const int GsGleichGw = 2;
private const int GwGleichKo = 4;
private const int KoGleichIn = 8;
private const int InGleichZt = 16;
private static readonly int[] Permutationen = new[]
{
720, // 00 Alle verschieden
360, // 01 St = Gs
360, // 02 Gs = Gw
120, // 03 St = Gs = Gw
360, // 04 Gw = Ko
180, // 05 St = Gs, Gw = Ko
120, // 06 Gs = Gw = Ko
30, // 07 St = Gs = Gw = Ko
360, // 08 Ko = In
180, // 09 St = Gs, Ko = In
180, // 10 Gs = Gw, Ko = In
60, // 11 St = Gs = Gw, Ko = In
120, // 12 Gw = Ko = In
60, // 13 St = Gs, Gw = Ko = In
30, // 14 Gs = Gw = Ko = In
6, // 15 St = Gs = Gw = Ko = In
360, // 16 In = Zt
180, // 17 St = Gs, In = Zt
180, // 18 Gs = Gw, In = Zt
60, // 19 St = Gs = Gw, In = Zt
180, // 20 Gw = Ko, In = Zt
90, // 21 St = Gs, Gw = Ko, In = Zt
60, // 22 Gs = Gw = Ko, In = Zt
15, // 23 St = Gs = Gw = Ko, In = Zt
120, // 24 Ko = In = Zt
60, // 25 St = Gs, Ko = In = Zt
60, // 26 Gs = Gw, Ko = In = Zt
20, // 27 St = Gs = Gw, Ko = In = Zt
30, // 28 Gw = Ko = In = Zt
15, // 29 St = Gs, Gw = Ko = In = Zt
6, // 30 Gs = Gw = Ko = In = Zt
1, // 31 St = Gs = Gw = Ko = In = Zt
};
static void Schnitt6Aus9()
{
for (var st = 101; --st > 0; )
{
var stGleichGs = StGleichGs;
for (var gs = st + 1; --gs > 0; )
{
var gsGleichGw = GsGleichGw;
for (var gw = gs + 1; --gw > 0; )
{
var stGsGw = st + gs + gw;
if (350 - stGsGw - 3 * gw > 0) break;
var gwGleichKo = GwGleichKo;
for (var ko = gw + 1; --ko > 0; )
{
var sum = 0L;
var anz = 0L;
var stGsGwKo = stGsGw + ko;
if (350 - stGsGwKo - (ko << 1) > 0) break;
var koGleichIn = KoGleichIn;
for (var i = ko + 1; --i > 0; )
{
var stGsGwKoIn = stGsGwKo + i;
if (350 - stGsGwKoIn - i > 0) break;
var inGleichZt = InGleichZt;
for (var zt = i + 1; --zt > 0; )
{
var stGsGwKoInZt = stGsGwKoIn + zt;
if (stGsGwKoInZt < 350) break;
var a = zt * zt * zt * Permutationen[stGleichGs | gsGleichGw | gwGleichKo | koGleichIn | inGleichZt];
anz += a;
sum += (long)a * stGsGwKoInZt;
inGleichZt = 0;
}
koGleichIn = 0;
}
_anz += anz;
_sum += sum;
gwGleichKo = 0;
}
gsGleichGw = 0;
}
stGleichGs = 0;
}
}
}
}
}
Wenn jemand da durchsteigt und das verifiziert bzw. einen Fehler findet, wäre das schön...
Gruß
Tony