Count the corners, edges and faces of a cut cube

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
7
down vote

favorite












Coming from this sandbox post



This is inspired from an 8th graders math test



Intro



We have a cube with following corners



A(0, 0, 0)
B(1, 0, 0)
C(1, 1, 0)
D(0, 1, 0)
E(0, 0, 1)
F(1, 0, 1)
G(1, 1, 1)
H(0, 1, 1)


This cube clearly has 8 corners, 12 edges and 6 faces. If we now cut off corner G, such that our cut plane goes exactly through the middle of each adjacent original edge, we add 2 new corners, 3 new edges and one new face. Please enjoy this hand drawn piece of art, for better clarification



enter image description here



Input



Given a list of corners (in this example identified by A-H), that will be cut off, compute the new number of corners, edges and faces.



You make take the input in any form you like, as long as it responds to the same corners (e.g. instead of A-H you can use 1-8 or 0-7, you can assume it to be a list, csv, whatever)



You can assume the list to be distinct (every corner will appear once at most), but it may be empty. The list will never contain non existing corners.



Output



Output three numbers corresponding to the number of corners, edges and faces. Output as a list is explicitly allowed.
Trailing whitespaces are allowed



Examples



 -> 8, 12, 6 (empty list) 
A -> 10, 15, 7
A,C -> 12, 18, 8
A,C,F -> 14, 21, 9
A,B,C -> 12, 19, 9
A,B,C,D -> 12, 20, 10


Finally, this is codegolf, thus the shortest answer in bytes wins. Please refrain from standard loopholes.










share|improve this question



















  • 2




    Interesting... So cutting off adjacent corners will mean they share one corner, and eliminate one edge? This is more complex than it seems at first
    – Jo King
    3 hours ago










  • Since imgur being blocked in Turkey, I can not see the image. Can you please send an alternate image link
    – Windmill Cookies
    3 hours ago










  • @JoKing yes that is correct.
    – infinitezero
    3 hours ago










  • @WindmillCookies I'm sorry, I didn't know that. I've used a different host now.
    – infinitezero
    3 hours ago






  • 1




    For example, may I use 0 for A, 1 for C, 2 for B, 3 for D, 4 for E, 5 for G, 6 for F, 7 for H? Or should I keep the order of ABCDEFGH?
    – tsh
    2 hours ago















up vote
7
down vote

favorite












Coming from this sandbox post



This is inspired from an 8th graders math test



Intro



We have a cube with following corners



A(0, 0, 0)
B(1, 0, 0)
C(1, 1, 0)
D(0, 1, 0)
E(0, 0, 1)
F(1, 0, 1)
G(1, 1, 1)
H(0, 1, 1)


This cube clearly has 8 corners, 12 edges and 6 faces. If we now cut off corner G, such that our cut plane goes exactly through the middle of each adjacent original edge, we add 2 new corners, 3 new edges and one new face. Please enjoy this hand drawn piece of art, for better clarification



enter image description here



Input



Given a list of corners (in this example identified by A-H), that will be cut off, compute the new number of corners, edges and faces.



You make take the input in any form you like, as long as it responds to the same corners (e.g. instead of A-H you can use 1-8 or 0-7, you can assume it to be a list, csv, whatever)



You can assume the list to be distinct (every corner will appear once at most), but it may be empty. The list will never contain non existing corners.



Output



Output three numbers corresponding to the number of corners, edges and faces. Output as a list is explicitly allowed.
Trailing whitespaces are allowed



Examples



 -> 8, 12, 6 (empty list) 
A -> 10, 15, 7
A,C -> 12, 18, 8
A,C,F -> 14, 21, 9
A,B,C -> 12, 19, 9
A,B,C,D -> 12, 20, 10


Finally, this is codegolf, thus the shortest answer in bytes wins. Please refrain from standard loopholes.










share|improve this question



















  • 2




    Interesting... So cutting off adjacent corners will mean they share one corner, and eliminate one edge? This is more complex than it seems at first
    – Jo King
    3 hours ago










  • Since imgur being blocked in Turkey, I can not see the image. Can you please send an alternate image link
    – Windmill Cookies
    3 hours ago










  • @JoKing yes that is correct.
    – infinitezero
    3 hours ago










  • @WindmillCookies I'm sorry, I didn't know that. I've used a different host now.
    – infinitezero
    3 hours ago






  • 1




    For example, may I use 0 for A, 1 for C, 2 for B, 3 for D, 4 for E, 5 for G, 6 for F, 7 for H? Or should I keep the order of ABCDEFGH?
    – tsh
    2 hours ago













up vote
7
down vote

favorite









up vote
7
down vote

favorite











Coming from this sandbox post



This is inspired from an 8th graders math test



Intro



We have a cube with following corners



A(0, 0, 0)
B(1, 0, 0)
C(1, 1, 0)
D(0, 1, 0)
E(0, 0, 1)
F(1, 0, 1)
G(1, 1, 1)
H(0, 1, 1)


This cube clearly has 8 corners, 12 edges and 6 faces. If we now cut off corner G, such that our cut plane goes exactly through the middle of each adjacent original edge, we add 2 new corners, 3 new edges and one new face. Please enjoy this hand drawn piece of art, for better clarification



enter image description here



Input



Given a list of corners (in this example identified by A-H), that will be cut off, compute the new number of corners, edges and faces.



You make take the input in any form you like, as long as it responds to the same corners (e.g. instead of A-H you can use 1-8 or 0-7, you can assume it to be a list, csv, whatever)



You can assume the list to be distinct (every corner will appear once at most), but it may be empty. The list will never contain non existing corners.



Output



Output three numbers corresponding to the number of corners, edges and faces. Output as a list is explicitly allowed.
Trailing whitespaces are allowed



Examples



 -> 8, 12, 6 (empty list) 
A -> 10, 15, 7
A,C -> 12, 18, 8
A,C,F -> 14, 21, 9
A,B,C -> 12, 19, 9
A,B,C,D -> 12, 20, 10


Finally, this is codegolf, thus the shortest answer in bytes wins. Please refrain from standard loopholes.










share|improve this question















Coming from this sandbox post



This is inspired from an 8th graders math test



Intro



We have a cube with following corners



A(0, 0, 0)
B(1, 0, 0)
C(1, 1, 0)
D(0, 1, 0)
E(0, 0, 1)
F(1, 0, 1)
G(1, 1, 1)
H(0, 1, 1)


This cube clearly has 8 corners, 12 edges and 6 faces. If we now cut off corner G, such that our cut plane goes exactly through the middle of each adjacent original edge, we add 2 new corners, 3 new edges and one new face. Please enjoy this hand drawn piece of art, for better clarification



enter image description here



Input



Given a list of corners (in this example identified by A-H), that will be cut off, compute the new number of corners, edges and faces.



You make take the input in any form you like, as long as it responds to the same corners (e.g. instead of A-H you can use 1-8 or 0-7, you can assume it to be a list, csv, whatever)



You can assume the list to be distinct (every corner will appear once at most), but it may be empty. The list will never contain non existing corners.



Output



Output three numbers corresponding to the number of corners, edges and faces. Output as a list is explicitly allowed.
Trailing whitespaces are allowed



Examples



 -> 8, 12, 6 (empty list) 
A -> 10, 15, 7
A,C -> 12, 18, 8
A,C,F -> 14, 21, 9
A,B,C -> 12, 19, 9
A,B,C,D -> 12, 20, 10


Finally, this is codegolf, thus the shortest answer in bytes wins. Please refrain from standard loopholes.







code-golf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago

























asked 3 hours ago









infinitezero

21613




21613







  • 2




    Interesting... So cutting off adjacent corners will mean they share one corner, and eliminate one edge? This is more complex than it seems at first
    – Jo King
    3 hours ago










  • Since imgur being blocked in Turkey, I can not see the image. Can you please send an alternate image link
    – Windmill Cookies
    3 hours ago










  • @JoKing yes that is correct.
    – infinitezero
    3 hours ago










  • @WindmillCookies I'm sorry, I didn't know that. I've used a different host now.
    – infinitezero
    3 hours ago






  • 1




    For example, may I use 0 for A, 1 for C, 2 for B, 3 for D, 4 for E, 5 for G, 6 for F, 7 for H? Or should I keep the order of ABCDEFGH?
    – tsh
    2 hours ago













  • 2




    Interesting... So cutting off adjacent corners will mean they share one corner, and eliminate one edge? This is more complex than it seems at first
    – Jo King
    3 hours ago










  • Since imgur being blocked in Turkey, I can not see the image. Can you please send an alternate image link
    – Windmill Cookies
    3 hours ago










  • @JoKing yes that is correct.
    – infinitezero
    3 hours ago










  • @WindmillCookies I'm sorry, I didn't know that. I've used a different host now.
    – infinitezero
    3 hours ago






  • 1




    For example, may I use 0 for A, 1 for C, 2 for B, 3 for D, 4 for E, 5 for G, 6 for F, 7 for H? Or should I keep the order of ABCDEFGH?
    – tsh
    2 hours ago








2




2




Interesting... So cutting off adjacent corners will mean they share one corner, and eliminate one edge? This is more complex than it seems at first
– Jo King
3 hours ago




Interesting... So cutting off adjacent corners will mean they share one corner, and eliminate one edge? This is more complex than it seems at first
– Jo King
3 hours ago












Since imgur being blocked in Turkey, I can not see the image. Can you please send an alternate image link
– Windmill Cookies
3 hours ago




Since imgur being blocked in Turkey, I can not see the image. Can you please send an alternate image link
– Windmill Cookies
3 hours ago












@JoKing yes that is correct.
– infinitezero
3 hours ago




@JoKing yes that is correct.
– infinitezero
3 hours ago












@WindmillCookies I'm sorry, I didn't know that. I've used a different host now.
– infinitezero
3 hours ago




@WindmillCookies I'm sorry, I didn't know that. I've used a different host now.
– infinitezero
3 hours ago




1




1




For example, may I use 0 for A, 1 for C, 2 for B, 3 for D, 4 for E, 5 for G, 6 for F, 7 for H? Or should I keep the order of ABCDEFGH?
– tsh
2 hours ago





For example, may I use 0 for A, 1 for C, 2 for B, 3 for D, 4 for E, 5 for G, 6 for F, 7 for H? Or should I keep the order of ABCDEFGH?
– tsh
2 hours ago











3 Answers
3






active

oldest

votes

















up vote
0
down vote














Perl 6, 59 58 bytes





6+@_,


Try it online!



Uses the numbers 0 to 7 to represent the corners. I probably shpuld have matched them up to the same order as in the question... oops? Outputs a list in the order faces, corners, edges.






share|improve this answer





























    up vote
    0
    down vote














    Charcoal, 48 45 bytes



    ≔Eθ↨℅ι²η≔⊘№⭆η⭆ηΣEι↔⁻§λξν1ηIE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


    Try it online! Link is to verbose version of code. Uses digits 0-7 to represent the letters ABDCEFHG in the diagram. Outputs in the order faces, corners, edges. Explanation:



    ≔Eθ↨℅ι²η


    Take the ASCII code of each character and convert it to base 2.



    ≔⊘№⭆η⭆η


    Take the cartesian product of the list of base 2 numbers with itself.



    ΣEι↔⁻§λξν1η


    XOR the pairs of base 2 numbers together and sum the number of 1 bits. Count how many pairs have a sum of 1 and divide that by 2. This gives the number of coincident corners.



    IE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


    Calculate and print the number of faces, corners and edges.






    share|improve this answer





























      up vote
      0
      down vote














      JavaScript (Node.js), 84 bytes





      a=>[a.map(u=>a.map(v=>j-=!!'ABCDAEFGHEFBCGHD'.match(u+v),n++,j+=2),n=j=6)|2+j,n+j,n]


      Try it online!






      share|improve this answer






















        Your Answer





        StackExchange.ifUsing("editor", function ()
        return StackExchange.using("mathjaxEditing", function ()
        StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
        StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
        );
        );
        , "mathjax-editing");

        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "200"
        ;
        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',
        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%2fcodegolf.stackexchange.com%2fquestions%2f175181%2fcount-the-corners-edges-and-faces-of-a-cut-cube%23new-answer', 'question_page');

        );

        Post as a guest






























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        0
        down vote














        Perl 6, 59 58 bytes





        6+@_,


        Try it online!



        Uses the numbers 0 to 7 to represent the corners. I probably shpuld have matched them up to the same order as in the question... oops? Outputs a list in the order faces, corners, edges.






        share|improve this answer


























          up vote
          0
          down vote














          Perl 6, 59 58 bytes





          6+@_,


          Try it online!



          Uses the numbers 0 to 7 to represent the corners. I probably shpuld have matched them up to the same order as in the question... oops? Outputs a list in the order faces, corners, edges.






          share|improve this answer
























            up vote
            0
            down vote










            up vote
            0
            down vote










            Perl 6, 59 58 bytes





            6+@_,


            Try it online!



            Uses the numbers 0 to 7 to represent the corners. I probably shpuld have matched them up to the same order as in the question... oops? Outputs a list in the order faces, corners, edges.






            share|improve this answer















            Perl 6, 59 58 bytes





            6+@_,


            Try it online!



            Uses the numbers 0 to 7 to represent the corners. I probably shpuld have matched them up to the same order as in the question... oops? Outputs a list in the order faces, corners, edges.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 2 hours ago

























            answered 3 hours ago









            Jo King

            18k24199




            18k24199




















                up vote
                0
                down vote














                Charcoal, 48 45 bytes



                ≔Eθ↨℅ι²η≔⊘№⭆η⭆ηΣEι↔⁻§λξν1ηIE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


                Try it online! Link is to verbose version of code. Uses digits 0-7 to represent the letters ABDCEFHG in the diagram. Outputs in the order faces, corners, edges. Explanation:



                ≔Eθ↨℅ι²η


                Take the ASCII code of each character and convert it to base 2.



                ≔⊘№⭆η⭆η


                Take the cartesian product of the list of base 2 numbers with itself.



                ΣEι↔⁻§λξν1η


                XOR the pairs of base 2 numbers together and sum the number of 1 bits. Count how many pairs have a sum of 1 and divide that by 2. This gives the number of coincident corners.



                IE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


                Calculate and print the number of faces, corners and edges.






                share|improve this answer


























                  up vote
                  0
                  down vote














                  Charcoal, 48 45 bytes



                  ≔Eθ↨℅ι²η≔⊘№⭆η⭆ηΣEι↔⁻§λξν1ηIE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


                  Try it online! Link is to verbose version of code. Uses digits 0-7 to represent the letters ABDCEFHG in the diagram. Outputs in the order faces, corners, edges. Explanation:



                  ≔Eθ↨℅ι²η


                  Take the ASCII code of each character and convert it to base 2.



                  ≔⊘№⭆η⭆η


                  Take the cartesian product of the list of base 2 numbers with itself.



                  ΣEι↔⁻§λξν1η


                  XOR the pairs of base 2 numbers together and sum the number of 1 bits. Count how many pairs have a sum of 1 and divide that by 2. This gives the number of coincident corners.



                  IE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


                  Calculate and print the number of faces, corners and edges.






                  share|improve this answer
























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote










                    Charcoal, 48 45 bytes



                    ≔Eθ↨℅ι²η≔⊘№⭆η⭆ηΣEι↔⁻§λξν1ηIE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


                    Try it online! Link is to verbose version of code. Uses digits 0-7 to represent the letters ABDCEFHG in the diagram. Outputs in the order faces, corners, edges. Explanation:



                    ≔Eθ↨℅ι²η


                    Take the ASCII code of each character and convert it to base 2.



                    ≔⊘№⭆η⭆η


                    Take the cartesian product of the list of base 2 numbers with itself.



                    ΣEι↔⁻§λξν1η


                    XOR the pairs of base 2 numbers together and sum the number of 1 bits. Count how many pairs have a sum of 1 and divide that by 2. This gives the number of coincident corners.



                    IE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


                    Calculate and print the number of faces, corners and edges.






                    share|improve this answer















                    Charcoal, 48 45 bytes



                    ≔Eθ↨℅ι²η≔⊘№⭆η⭆ηΣEι↔⁻§λξν1ηIE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


                    Try it online! Link is to verbose version of code. Uses digits 0-7 to represent the letters ABDCEFHG in the diagram. Outputs in the order faces, corners, edges. Explanation:



                    ≔Eθ↨℅ι²η


                    Take the ASCII code of each character and convert it to base 2.



                    ≔⊘№⭆η⭆η


                    Take the cartesian product of the list of base 2 numbers with itself.



                    ΣEι↔⁻§λξν1η


                    XOR the pairs of base 2 numbers together and sum the number of 1 bits. Count how many pairs have a sum of 1 and divide that by 2. This gives the number of coincident corners.



                    IE⟦⁶⁻⁸η⁻¹²η⟧⁺ι×⊕κLθ


                    Calculate and print the number of faces, corners and edges.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 2 hours ago

























                    answered 2 hours ago









                    Neil

                    77.2k744174




                    77.2k744174




















                        up vote
                        0
                        down vote














                        JavaScript (Node.js), 84 bytes





                        a=>[a.map(u=>a.map(v=>j-=!!'ABCDAEFGHEFBCGHD'.match(u+v),n++,j+=2),n=j=6)|2+j,n+j,n]


                        Try it online!






                        share|improve this answer


























                          up vote
                          0
                          down vote














                          JavaScript (Node.js), 84 bytes





                          a=>[a.map(u=>a.map(v=>j-=!!'ABCDAEFGHEFBCGHD'.match(u+v),n++,j+=2),n=j=6)|2+j,n+j,n]


                          Try it online!






                          share|improve this answer
























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote










                            JavaScript (Node.js), 84 bytes





                            a=>[a.map(u=>a.map(v=>j-=!!'ABCDAEFGHEFBCGHD'.match(u+v),n++,j+=2),n=j=6)|2+j,n+j,n]


                            Try it online!






                            share|improve this answer















                            JavaScript (Node.js), 84 bytes





                            a=>[a.map(u=>a.map(v=>j-=!!'ABCDAEFGHEFBCGHD'.match(u+v),n++,j+=2),n=j=6)|2+j,n+j,n]


                            Try it online!







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 1 hour ago

























                            answered 2 hours ago









                            tsh

                            7,95611346




                            7,95611346



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175181%2fcount-the-corners-edges-and-faces-of-a-cut-cube%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Comments

                                Popular posts from this blog

                                What does second last employer means? [closed]

                                Installing NextGIS Connect into QGIS 3?

                                One-line joke