Setup¶

In [1]:
import copy
import numpy as np
import pandas as pd
from random import randint as RI
import string
import time

Constants and Functions¶

In [10]:
#3 horizontal,
#3 vertical,
#2 diagonals
WINS = [{3, 4, 5},
        {6, 7, 8},
        {9, 10, 11},
        {3, 6, 9},
        {4, 7, 10},
        {5, 8, 11},
        {3, 7, 11},
        {5, 7, 9}]


def dice36() :
    
    """
    Creates 36 dice rolls.

    Parameters:
    none
    
    Returns:
    rolls - List of 36 ordered pairs (d1, d2), the sample space of two dice.
    """
    
    #Output list.
    rolls = []
    
    for i in range(1, 7) :
        for j in range(1, 7) :
            rolls.append((i, j))

    return(rolls)



def countWins() :
    
    """
    Counts wins in Tic-Tac-Deal 2.0 for d dice.

    Parameters:
    d - Number of dice rolled
    
    Returns:
    wins
    """
    start = time.time()
    W = 0
    
    
    for r1 in dice36() :
        for r2 in dice36() :
            for r3 in dice36() :
                for r4 in dice36() :
                    for r5 in dice36() :
                        for r6 in dice36() :
                            result = {sum(r1), sum(r2), sum(r3), sum(r4), sum(r5), sum(r6)}
                            for w in WINS :
                                if w.issubset(result) :
                                    W += 1
                                    break

    print(time.time() - start)
    return(W)
In [3]:
countWins()
0.028487682342529297
Out[3]:
2712
In [5]:
countWins()
1.4821679592132568
Out[5]:
319200
In [8]:
countWins()
59.658780574798584
Out[8]:
21849720
In [11]:
countWins()
2257.910097837448
Out[11]:
1148595600

Rohan Lewis¶

2025.10.13¶