Project Euler 90 - Cube Digit Pairs

Official link: https://projecteuler.net/problem=90

Thought Process

There are 10 Choose 6 = 210 possibilities for each dice, which means that there are 44,100 total combinations, this seems fairly easy to brute force, which is exactly what I will do.

I made 3 functions:

  1. dicecomb()

    • Generates a list will all 210 tuples where each tuple contains 6 numbers representing the 6 digits on the die

  2. valid_dice_pair(dice1, dice2)

    • The function takes 2 different die and will check if they are able to form the 9 square numbers: [(0,1), (0,4), (0,9), (1,6), (2,5), (3,6), (4,9), (6,4), (8,1)]

    • Goes through both die and add all tuples (x,y) and (y,x) to a set, make sure to make a special for 6 and 9

    • If this set contains all the square numbers return True otherwise return False

  3. compute()

    • creates a list dice = dicecomb()

    • Go through the list dice in a double loop, making sure not to count the same situations, and I check if the 2 dice form a valid pair using valid_dice_pair(dice1, dice2)

Interactive Code

No interactive code for this problem, my code is given below