| D |
| E | A | B | F |
| C |
The ASCII art above shows the net of a general 6-sided die. There is a number written on each of the six sides. In the picture, these numbers are denoted A to F.
(The net is folded so that the numbers are on the outside, but this information is not necessary to solve the following problem.)
The numbers A to F will be given to you as a int values, where A will be values, B will be values, and so on.
You have N^3 identical dice, each one matching the net shown above. You want to take all the dice, rotate some of them, and assemble a N×N×N cube. The cube will be standing on a table, hence only 5 of its sides will be visible.
You are given the int N, and the int values.
Write a method that will return the smallest possible sum of the 5N^2 visible faces of the dice.