Two-Cube Calendar

Manipulate[SeedRandom[ranint];Module[{v={{-1,0},{0,0},{1,0},{1.25,.125Sqrt[3]},{-1.25,0.125Sqrt[3]},{-1,1},{0,1},{1,1},{1.25,1+0.125Sqrt[3]},{0,1+0.125Sqrt[3]},{-1.25,1+0.125Sqrt[3]}},a1,a2,a3,a4,a5,a6,md,ml,kk1,kk},a1=RandomInteger[{0,3}];
a4=If[a1==3,RandomInteger[{0,1}],RandomInteger[{3,8}]];
If[MemberQ[Range[3,8],a4],{a5,a6}=RandomSample[Complement[Range[3,8],{a4}],2];{a2,a3}=RandomSample[Complement[Range[0,8],{a1,a4,a5,a6}],2];ml=Complement[Range[0,8],{a1,a2,a3,a4,a5,a6}]];
If[MemberQ[Range[0,1],a4],{a2,a3}=RandomSample[Complement[Range[3,8],{a1}],2];{a5,a6}=RandomSample[Complement[Range[0,8],{a1,a4,a2,a3}],2];md=Complement[Range[0,8],{a1,a2,a3,a4,a5,a6}]];
kk1=Plus@@If[a1==3,md,ml];
kk=Sort[RandomSample[Union[{kk1},Range[5,15]],5]];

Text@Column[{Graphics[{{RGBColor[0.501961, 1, 0.501961],Polygon[v[[#]]&@{1,3,4,9,11,5}]},GraphicsComplex[v,{Line[{1,2,7,6,1}],Line[{2,3,8,7,2}],Line[{3,4,9,8,3}],Line[{7,8,9,10,7}],Line[{6,7,10,11,6}],Line[{1,6,11,5,1}]}],Text[Style[a1,50],(v[[1]]+v[[2]]+v[[7]]+v[[6]])/4],Text[Style[a2,30],(v[[1]]+v[[6]]+v[[11]]+v[[5]])/4],Text[Style[a3,20],(v[[6]]+v[[7]]+v[[10]]+v[[11]])/4],Text[Style[a4,50],(v[[2]]+v[[3]]+v[[8]]+v[[7]])/4],Text[Style[a5,30],(v[[3]]+v[[4]]+v[[9]]+v[[8]])/4],Text[Style[a6,20],(v[[7]]+v[[8]]+v[[9]]+v[[10]])/4]},ImageSize->{380,300}],Row[{"What is the sum of the three digits that cannot be seen on the ",If[a1==3,Style["right ",Bold,Red],Style["left ",Bold,Blue]],"cube?" }],
Grid[{{SetterBar[Dynamic[an],kk]},
{If[an==0,Invisible[False],If[an==kk1,True,False]]}},ItemSize->15]},Alignment->Center]],{ranint,RandomInteger[{199,199977}],ControlType->None},
Button["click for a problem",ranint=Random[Integer,{1,123577}];an=0],{ans,{False,True},ControlType->None},
{an,0,ControlType->None}]

Each face of two cubes is labeled by single digit, 0 through 9, and it is possible to indicate on front faces any date from 01, 02, ..., to 31. The problem is to determine the sum of digits that cannot be seen.

See the details for a hint.

Each cube must have faces with 0, 1, and 2, leaving six faces with 3, 4, 5, 6, 7, 8; the face with 6 can be turned upside down to be 9.

[1] Martin Gardner, The Colossal Book of Short Puzzles and Problems, W. W. Norton & Company, New York 2006, pp. 4, 18.

Contributed by: Izidor Hafner