How to shuffle a Rubik's cube?












6















documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
usepackage{arrayjob}
begin{document}

newarraycolors
readarray{colors}{red&red&red&red&red&red&red&red&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&orange&orange&orange&orange&orange&orange&orange&orange&orange&green&green&green&green&green&green&green&green&green&blue&blue&blue&blue&blue&blue&blue&blue&blue}

edefcolorfaces{}%
multido{i=0+1}{57}{%
checkcolors(i)
xdefcolorfaces{colorfacesispace(cachedata)space}}
%
deffigure#1#2{%
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=colorfaces%
,Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



Question:




  1. Is there an another way without using the package arrayjob?


  2. How to get the random color for it?



Thanks.










share|improve this question




















  • 1





    As for 2.: you are already loading pgf, so you have already a built in way to get a random item. Just add pgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c} to your code.

    – marmot
    Feb 21 at 14:51











  • It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.

    – John Kormylo
    Feb 21 at 23:47













  • Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.

    – The Inventor of God
    Feb 22 at 3:13
















6















documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
usepackage{arrayjob}
begin{document}

newarraycolors
readarray{colors}{red&red&red&red&red&red&red&red&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&orange&orange&orange&orange&orange&orange&orange&orange&orange&green&green&green&green&green&green&green&green&green&blue&blue&blue&blue&blue&blue&blue&blue&blue}

edefcolorfaces{}%
multido{i=0+1}{57}{%
checkcolors(i)
xdefcolorfaces{colorfacesispace(cachedata)space}}
%
deffigure#1#2{%
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=colorfaces%
,Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



Question:




  1. Is there an another way without using the package arrayjob?


  2. How to get the random color for it?



Thanks.










share|improve this question




















  • 1





    As for 2.: you are already loading pgf, so you have already a built in way to get a random item. Just add pgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c} to your code.

    – marmot
    Feb 21 at 14:51











  • It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.

    – John Kormylo
    Feb 21 at 23:47













  • Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.

    – The Inventor of God
    Feb 22 at 3:13














6












6








6








documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
usepackage{arrayjob}
begin{document}

newarraycolors
readarray{colors}{red&red&red&red&red&red&red&red&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&orange&orange&orange&orange&orange&orange&orange&orange&orange&green&green&green&green&green&green&green&green&green&blue&blue&blue&blue&blue&blue&blue&blue&blue}

edefcolorfaces{}%
multido{i=0+1}{57}{%
checkcolors(i)
xdefcolorfaces{colorfacesispace(cachedata)space}}
%
deffigure#1#2{%
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=colorfaces%
,Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



Question:




  1. Is there an another way without using the package arrayjob?


  2. How to get the random color for it?



Thanks.










share|improve this question
















documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
usepackage{arrayjob}
begin{document}

newarraycolors
readarray{colors}{red&red&red&red&red&red&red&red&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&yellow&orange&orange&orange&orange&orange&orange&orange&orange&orange&green&green&green&green&green&green&green&green&green&blue&blue&blue&blue&blue&blue&blue&blue&blue}

edefcolorfaces{}%
multido{i=0+1}{57}{%
checkcolors(i)
xdefcolorfaces{colorfacesispace(cachedata)space}}
%
deffigure#1#2{%
psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=colorfaces%
,Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



Question:




  1. Is there an another way without using the package arrayjob?


  2. How to get the random color for it?



Thanks.







pstricks pst-solides3d






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 22 at 3:11









The Inventor of God

4,93211041




4,93211041










asked Feb 21 at 13:21









chishimutojichishimutoji

8201320




8201320








  • 1





    As for 2.: you are already loading pgf, so you have already a built in way to get a random item. Just add pgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c} to your code.

    – marmot
    Feb 21 at 14:51











  • It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.

    – John Kormylo
    Feb 21 at 23:47













  • Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.

    – The Inventor of God
    Feb 22 at 3:13














  • 1





    As for 2.: you are already loading pgf, so you have already a built in way to get a random item. Just add pgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c} to your code.

    – marmot
    Feb 21 at 14:51











  • It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.

    – John Kormylo
    Feb 21 at 23:47













  • Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.

    – The Inventor of God
    Feb 22 at 3:13








1




1





As for 2.: you are already loading pgf, so you have already a built in way to get a random item. Just add pgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c} to your code.

– marmot
Feb 21 at 14:51





As for 2.: you are already loading pgf, so you have already a built in way to get a random item. Just add pgfmathdeclarerandomlist{colors}{{red}{red}{red}{red}{red}{red}{red}{red}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{yellow}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{orange}{green}{green}{green}{green}{green}{green}{green}{green}{green}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}{blue}} pgfmathrandomitem{c}{colors} typeout{c} to your code.

– marmot
Feb 21 at 14:51













It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.

– John Kormylo
Feb 21 at 23:47







It occurred to me that random colors may not be a good idea. There are six colors, eight corners and eight edges. Each edge has a unique combination of 2 colors, and each corner has a unique combination of 3 colors, of which each color is used in precisely 4 corners and 4 edges. And each of 6 centers has a different color. What you really need is a random sort of the different components.

– John Kormylo
Feb 21 at 23:47















Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.

– The Inventor of God
Feb 22 at 3:13





Because the colors are not freely randomized but they must follow some rules, I think I need to change the title to be more specific.

– The Inventor of God
Feb 22 at 3:13










1 Answer
1






active

oldest

votes


















5














documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



 0 1 8 {      from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop


Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.



The same for complete faces:



documentclass[pstricks,border=10pt]{standalone}

usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here






share|improve this answer


























  • Please to answer the first question. Your code(PostScript language) is new with me...

    – chishimutoji
    Feb 21 at 16:36













  • see edited answer ...

    – Herbert
    Feb 21 at 16:45











  • Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..

    – chishimutoji
    Feb 21 at 16:54













  • And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)

    – chishimutoji
    Feb 21 at 17:02











  • I see only 5 colors. pages 38ff show anything about colors.

    – Herbert
    Feb 21 at 17:09











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475995%2fhow-to-shuffle-a-rubiks-cube%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



 0 1 8 {      from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop


Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.



The same for complete faces:



documentclass[pstricks,border=10pt]{standalone}

usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here






share|improve this answer


























  • Please to answer the first question. Your code(PostScript language) is new with me...

    – chishimutoji
    Feb 21 at 16:36













  • see edited answer ...

    – Herbert
    Feb 21 at 16:45











  • Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..

    – chishimutoji
    Feb 21 at 16:54













  • And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)

    – chishimutoji
    Feb 21 at 17:02











  • I see only 5 colors. pages 38ff show anything about colors.

    – Herbert
    Feb 21 at 17:09
















5














documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



 0 1 8 {      from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop


Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.



The same for complete faces:



documentclass[pstricks,border=10pt]{standalone}

usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here






share|improve this answer


























  • Please to answer the first question. Your code(PostScript language) is new with me...

    – chishimutoji
    Feb 21 at 16:36













  • see edited answer ...

    – Herbert
    Feb 21 at 16:45











  • Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..

    – chishimutoji
    Feb 21 at 16:54













  • And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)

    – chishimutoji
    Feb 21 at 17:02











  • I see only 5 colors. pages 38ff show anything about colors.

    – Herbert
    Feb 21 at 17:09














5












5








5







documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



 0 1 8 {      from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop


Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.



The same for complete faces:



documentclass[pstricks,border=10pt]{standalone}

usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here






share|improve this answer















documentclass[pstricks,border=10pt]{standalone}
usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { Colors Rand 4.5 mul cvi get } for
9 1 17 { Colors Rand 4.5 mul cvi get } for
18 1 26 { Colors Rand 4.5 mul cvi get } for
27 1 35 { Colors Rand 4.5 mul cvi get } for
36 1 44 { Colors Rand 4.5 mul cvi get } for
45 1 53 { Colors Rand 4.5 mul cvi get } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here



 0 1 8 {      from 0 to 8 with step 1 do
put the loop variable on the stack
Colors. Load Color array
Rand get a random number between 0 and 1
4.5 mul between 0 and 4.5
cvi between 0 and 4
get load color with random number
} for. end of for loop


Every square has a corresponding number 0 .. 53 which can be used
for color setting: 0 (red) 1 (green) ... and so on. see pages 38 ff of
the documentation.



The same for complete faces:



documentclass[pstricks,border=10pt]{standalone}

usepackage{pst-solides3d}
begin{document}

psset{viewpoint=120 50 30 rtp2xyz,Decran=50}
pstVerb{/Colors [(red)(yellow)(orange)(green)(blue)] def }
deffigure#1#2{%
begin{pspicture}(-3,-3)(3,3)
psSolid[a=8,object=cube,ngrid=3,%
fcol=
0 1 8 { (red) } for
9 1 17 { (green) } for
18 1 26 { (blue) } for
27 1 35 { (orange) } for
36 1 44 { (yellow) } for
45 1 53 { (cyan) } for,
Rot#2=-#1space]%
end{pspicture}
}
multido{iA=0+10}{36}{figure{iA}{X}}
multido{iA=0+10}{36}{figure{iA}{Y}}
multido{iA=0+10}{36}{figure{iA}{Z}}
end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 21 at 17:17

























answered Feb 21 at 16:08









HerbertHerbert

275k24418730




275k24418730













  • Please to answer the first question. Your code(PostScript language) is new with me...

    – chishimutoji
    Feb 21 at 16:36













  • see edited answer ...

    – Herbert
    Feb 21 at 16:45











  • Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..

    – chishimutoji
    Feb 21 at 16:54













  • And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)

    – chishimutoji
    Feb 21 at 17:02











  • I see only 5 colors. pages 38ff show anything about colors.

    – Herbert
    Feb 21 at 17:09



















  • Please to answer the first question. Your code(PostScript language) is new with me...

    – chishimutoji
    Feb 21 at 16:36













  • see edited answer ...

    – Herbert
    Feb 21 at 16:45











  • Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..

    – chishimutoji
    Feb 21 at 16:54













  • And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)

    – chishimutoji
    Feb 21 at 17:02











  • I see only 5 colors. pages 38ff show anything about colors.

    – Herbert
    Feb 21 at 17:09

















Please to answer the first question. Your code(PostScript language) is new with me...

– chishimutoji
Feb 21 at 16:36







Please to answer the first question. Your code(PostScript language) is new with me...

– chishimutoji
Feb 21 at 16:36















see edited answer ...

– Herbert
Feb 21 at 16:45





see edited answer ...

– Herbert
Feb 21 at 16:45













Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..

– chishimutoji
Feb 21 at 16:54







Oh, you misunderstood me. I mean that you can rewrite my code as the smart way.( my figure only 6 colors). The second question is not important. :-) And of course thanks for your expansion..

– chishimutoji
Feb 21 at 16:54















And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)

– chishimutoji
Feb 21 at 17:02





And I just check pages 38 of the documentation BUT there is no anything as you can see. :-)

– chishimutoji
Feb 21 at 17:02













I see only 5 colors. pages 38ff show anything about colors.

– Herbert
Feb 21 at 17:09





I see only 5 colors. pages 38ff show anything about colors.

– Herbert
Feb 21 at 17:09


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475995%2fhow-to-shuffle-a-rubiks-cube%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents