20 minutes ago, sozin said:Post your code @MajorJuggler , I will see if I can get a better golfing score with Python
![]()
Funny part was I wasn't even really trying to make it short... convolution function calls are a wonderful thing.
function WinningOdds = FinalSalvoOdds(YourDice, OpponentDice)
Dist_You = 1;
for dice = 1:YourDice
Dist_You = conv(Dist_You, [0.5 0.5]);
end
Dist_Opponent = 1;
for dice = 1:OpponentDice
Dist_Opponent = conv(Dist_Opponent, [0.5 0.5]);
end
NetDist = conv(Dist_You, fliplr(Dist_Opponent));
WinningOdds = sum(NetDist(end-YourDice+1:end)) / (1 - NetDist(end-YourDice));
end
It can go to 11 pretty easily...
function WinningOdds = FinalSalvoOdds(YourDice, OpponentDice)
Dist_You = 1; Dist_Opponent = 1;
for dice = 1:YourDice
Dist_You = conv(Dist_You, [0.5 0.5]);
end
for dice = 1:OpponentDice
Dist_Opponent = conv(Dist_Opponent, [0.5 0.5]);
end
NetDist = conv(Dist_You, fliplr(Dist_Opponent));
WinningOdds = sum(NetDist(end-YourDice+1:end)) / (1 - NetDist(end-YourDice));
end