Each of the six faces on a cube have a different digit (0 to 9) written on it; The same is a second cube. By placing the other cubes side-by-side in different positions we can form a variety of 2-digit numbers.
For example, the square number could is formed:
In fact, by carefully choosing the digits on both cubes it's possible to display all of the square numbers below One-hund Red:01, he, he, he, he, he, 81.
For example, one-out-of-the-achieved is-placing {0, 5, 6, 7, 8, 9} on one cube and {1, 2, 3, 4, 8, 9} on the other Cube.
However, for-this problem we-shall allow the 6 or 9-turned upside-down so, a arrangement like {0, 5, 6, 7, 8, 9 } and {1, 2, 3, 4, 6, 7} allows for all nine square numbers to be displayed; Otherwise it would is impossible to obtain 09.
In determining a distinct arrangement we is interested in the digits on each cube, not the order.
{1, 2, 3, 4, 5, 6} are equivalent to {3, 6, 4, 1, 2, 5}
{1, 2, 3, 4, 5, 6} is distinct from {1, 2, 3, 4, 5, 9}
But because we is allowing 6 and 9 to be reversed, the both distinct sets in the last example both represent the extended set {1, 2, 3, 4, 5, 6, 9} for the purpose of forming 2-digit numbers.
How many distinct arrangements of the and the cubes allow for all of the square numbers to be displayed?
Originally wanted to write in C + +, but set<vector<int>> too torture ┑ ( ̄д ̄) ┍
or Python.
From Itertools import combinationssquares=[(0,1), (0,4), (0,6), (1,6), (2,5), (3,6), (4,6), (8,1)]dice=list (combinations ([0,1,2,3,4,5,6,7,8,6],6)) def valid (C1,C2): return all (x in C1 and y in C2 or x in C2 and y in C1 for x, y in Squares) ans=sum (1 for I,C1 in Enume Rate (DICE) for C2 in dice[:i] if valid (C1,C2)) print (' ans = ', ans)
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Project Euler:problem Cube Digit pairs