Print last inputted byte












3












$begingroup$


Challenge



You have one string of input bytes, output the last byte in it.



Rules



Your submission may be a program or function outputting the last byte in the input which




  • is either a string, stdin or command-line arguments, and

  • is non-empty.


I was trying to solve this with brainfuck, however all languages are allowed to participate. This is code-golf.



Examples



"?" -> "?"
"29845812674" -> "4"









share|improve this question









New contributor




jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    I mean I have input: 29845812674 and output should be: 4
    $endgroup$
    – jean
    3 hours ago








  • 3




    $begingroup$
    Welcome to PPCG! We host competitions on this side which are often answered in esoteric languages, but this is not the right place to ask how to solve a specific problem in a specific language. Such questions belong on Stack overflow, though you should describe what you have already tried and where you are stuck.
    $endgroup$
    – Laikoni
    2 hours ago






  • 1




    $begingroup$
    Welcome, I changed your question to fit our format more properly (note this is what the sandbox is for, usually). However in its current state the challenge is very easy (also in bf), so not sure about that.
    $endgroup$
    – ბიმო
    2 hours ago
















3












$begingroup$


Challenge



You have one string of input bytes, output the last byte in it.



Rules



Your submission may be a program or function outputting the last byte in the input which




  • is either a string, stdin or command-line arguments, and

  • is non-empty.


I was trying to solve this with brainfuck, however all languages are allowed to participate. This is code-golf.



Examples



"?" -> "?"
"29845812674" -> "4"









share|improve this question









New contributor




jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    I mean I have input: 29845812674 and output should be: 4
    $endgroup$
    – jean
    3 hours ago








  • 3




    $begingroup$
    Welcome to PPCG! We host competitions on this side which are often answered in esoteric languages, but this is not the right place to ask how to solve a specific problem in a specific language. Such questions belong on Stack overflow, though you should describe what you have already tried and where you are stuck.
    $endgroup$
    – Laikoni
    2 hours ago






  • 1




    $begingroup$
    Welcome, I changed your question to fit our format more properly (note this is what the sandbox is for, usually). However in its current state the challenge is very easy (also in bf), so not sure about that.
    $endgroup$
    – ბიმო
    2 hours ago














3












3








3





$begingroup$


Challenge



You have one string of input bytes, output the last byte in it.



Rules



Your submission may be a program or function outputting the last byte in the input which




  • is either a string, stdin or command-line arguments, and

  • is non-empty.


I was trying to solve this with brainfuck, however all languages are allowed to participate. This is code-golf.



Examples



"?" -> "?"
"29845812674" -> "4"









share|improve this question









New contributor




jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




Challenge



You have one string of input bytes, output the last byte in it.



Rules



Your submission may be a program or function outputting the last byte in the input which




  • is either a string, stdin or command-line arguments, and

  • is non-empty.


I was trying to solve this with brainfuck, however all languages are allowed to participate. This is code-golf.



Examples



"?" -> "?"
"29845812674" -> "4"






code-golf string






share|improve this question









New contributor




jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 1 hour ago









SuperJedi224

9,78013363




9,78013363






New contributor




jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









jeanjean

161




161




New contributor




jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






jean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • $begingroup$
    I mean I have input: 29845812674 and output should be: 4
    $endgroup$
    – jean
    3 hours ago








  • 3




    $begingroup$
    Welcome to PPCG! We host competitions on this side which are often answered in esoteric languages, but this is not the right place to ask how to solve a specific problem in a specific language. Such questions belong on Stack overflow, though you should describe what you have already tried and where you are stuck.
    $endgroup$
    – Laikoni
    2 hours ago






  • 1




    $begingroup$
    Welcome, I changed your question to fit our format more properly (note this is what the sandbox is for, usually). However in its current state the challenge is very easy (also in bf), so not sure about that.
    $endgroup$
    – ბიმო
    2 hours ago


















  • $begingroup$
    I mean I have input: 29845812674 and output should be: 4
    $endgroup$
    – jean
    3 hours ago








  • 3




    $begingroup$
    Welcome to PPCG! We host competitions on this side which are often answered in esoteric languages, but this is not the right place to ask how to solve a specific problem in a specific language. Such questions belong on Stack overflow, though you should describe what you have already tried and where you are stuck.
    $endgroup$
    – Laikoni
    2 hours ago






  • 1




    $begingroup$
    Welcome, I changed your question to fit our format more properly (note this is what the sandbox is for, usually). However in its current state the challenge is very easy (also in bf), so not sure about that.
    $endgroup$
    – ბიმო
    2 hours ago
















$begingroup$
I mean I have input: 29845812674 and output should be: 4
$endgroup$
– jean
3 hours ago






$begingroup$
I mean I have input: 29845812674 and output should be: 4
$endgroup$
– jean
3 hours ago






3




3




$begingroup$
Welcome to PPCG! We host competitions on this side which are often answered in esoteric languages, but this is not the right place to ask how to solve a specific problem in a specific language. Such questions belong on Stack overflow, though you should describe what you have already tried and where you are stuck.
$endgroup$
– Laikoni
2 hours ago




$begingroup$
Welcome to PPCG! We host competitions on this side which are often answered in esoteric languages, but this is not the right place to ask how to solve a specific problem in a specific language. Such questions belong on Stack overflow, though you should describe what you have already tried and where you are stuck.
$endgroup$
– Laikoni
2 hours ago




1




1




$begingroup$
Welcome, I changed your question to fit our format more properly (note this is what the sandbox is for, usually). However in its current state the challenge is very easy (also in bf), so not sure about that.
$endgroup$
– ბიმო
2 hours ago




$begingroup$
Welcome, I changed your question to fit our format more properly (note this is what the sandbox is for, usually). However in its current state the challenge is very easy (also in bf), so not sure about that.
$endgroup$
– ბიმო
2 hours ago










15 Answers
15






active

oldest

votes


















2












$begingroup$

Brainf***, 7 bytes



,[>,]<.





share|improve this answer









$endgroup$













  • $begingroup$
    ideone.com/XoJLD0 It still doesn't work ;(
    $endgroup$
    – jean
    53 mins ago










  • $begingroup$
    @jean Try it here. (Honestly, I didn't even know ideone did BF).
    $endgroup$
    – SuperJedi224
    49 mins ago












  • $begingroup$
    Yes, in your link everything works fine. But online judge for this problem uses ideone where it doesn't work ;(
    $endgroup$
    – jean
    43 mins ago












  • $begingroup$
    @jean ideone seems to use -1 as the EOF. +[>,+]<-. should work
    $endgroup$
    – Jo King
    6 mins ago



















2












$begingroup$

Javascript, 14 bytes



a=>a.slice(-1)





share|improve this answer









$endgroup$





















    2












    $begingroup$


    Jelly, 1 byte






    Try it online!



    Not the most difficult challenge in Jelly...






    share|improve this answer









    $endgroup$





















      1












      $begingroup$


      Python 3, 14 bytes





      lambda x:x[-1]


      Try it online!






      share|improve this answer









      $endgroup$





















        1












        $begingroup$


        Haskell, 9 bytes





        pure.last


        Try it online!






        share|improve this answer









        $endgroup$





















          1












          $begingroup$

          PowerShell, 11 bytes



          "$args"[-1]


          Try it online!






          share|improve this answer









          $endgroup$





















            1












            $begingroup$


            Befunge-93, 15 bytes



            >~# :1+_$$$1-,@


            Try it online!



            I bet this could be golfed further, but I'm still trying to get the hang of befunge-93.



            Alternate 15 byte version that is less messy:



            ~:1+#v!_
            @,$<


            Taking strings as input in Befunge isn't the easiest. If there were a single command to take in multiple characters, it would be as simple as reading the string, popping/printing the top character, and exiting.






            share|improve this answer











            $endgroup$













            • $begingroup$
              12 bytes
              $endgroup$
              – Jo King
              4 mins ago



















            1












            $begingroup$

            MATL, 2 bytes



            0)


            MATL uses 1-based modular indexing so this solution grabs the element in the 0-th position of the input which is the same as the last since the 0 wraps around to the end.



            Try it out at MATL Online






            share|improve this answer









            $endgroup$





















              1












              $begingroup$


              Cubix, 6 bytes



              pA/@po


              Try it online!



                p
              A / @ p
              o


              Watch it run





              • A Takes all the input


              • / Redirect around the cube


              • pp bring bottom of the stack to the top twice


              • o/@ output as character, redirect and halt





              share









              $endgroup$





















                0












                $begingroup$

                Java 8



                Input from STDIN, 71 bytes



                v->{int i=0;for(;System.in.available()>0;i=System.in.read());return i;}


                Try it online!



                Function Argument, 25 bytes



                s->s.charAt(s.length()-1)





                share|improve this answer











                $endgroup$





















                  0












                  $begingroup$

                  TI-BASIC (TI-84), 10 bytes



                  sub(Ans,length(Ans),1


                  Gets the last character in the input string.

                  Input is in Ans.

                  Output is in Ans and is automatically printed out when the program finishes.






                  share|improve this answer









                  $endgroup$





















                    0












                    $begingroup$


                    Wolfram Language (Mathematica), 16 bytes



                    #~StringTake~-1&


                    Try it online!






                    share|improve this answer









                    $endgroup$





















                      0












                      $begingroup$


                      ><>, 2 bytes



                      Using command line args



                      o;


                      Try it online!




                      ><>, 11 bytes



                      Using stdin



                      ~o;
                      /?(0:i


                      Try it online!






                      share|improve this answer









                      $endgroup$





















                        0












                        $begingroup$

                        SmileBASIC, 16 bytes



                        INPUT S$?POP(S$)




                        share









                        $endgroup$





















                          0












                          $begingroup$


                          05AB1E, 1 byte



                          ¤


                          Try it online!



                          θ or ` would also work.





                          share









                          $endgroup$













                            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',
                            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
                            });


                            }
                            });






                            jean is a new contributor. Be nice, and check out our Code of Conduct.










                            draft saved

                            draft discarded


















                            StackExchange.ready(
                            function () {
                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181627%2fprint-last-inputted-byte%23new-answer', 'question_page');
                            }
                            );

                            Post as a guest















                            Required, but never shown

























                            15 Answers
                            15






                            active

                            oldest

                            votes








                            15 Answers
                            15






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes









                            2












                            $begingroup$

                            Brainf***, 7 bytes



                            ,[>,]<.





                            share|improve this answer









                            $endgroup$













                            • $begingroup$
                              ideone.com/XoJLD0 It still doesn't work ;(
                              $endgroup$
                              – jean
                              53 mins ago










                            • $begingroup$
                              @jean Try it here. (Honestly, I didn't even know ideone did BF).
                              $endgroup$
                              – SuperJedi224
                              49 mins ago












                            • $begingroup$
                              Yes, in your link everything works fine. But online judge for this problem uses ideone where it doesn't work ;(
                              $endgroup$
                              – jean
                              43 mins ago












                            • $begingroup$
                              @jean ideone seems to use -1 as the EOF. +[>,+]<-. should work
                              $endgroup$
                              – Jo King
                              6 mins ago
















                            2












                            $begingroup$

                            Brainf***, 7 bytes



                            ,[>,]<.





                            share|improve this answer









                            $endgroup$













                            • $begingroup$
                              ideone.com/XoJLD0 It still doesn't work ;(
                              $endgroup$
                              – jean
                              53 mins ago










                            • $begingroup$
                              @jean Try it here. (Honestly, I didn't even know ideone did BF).
                              $endgroup$
                              – SuperJedi224
                              49 mins ago












                            • $begingroup$
                              Yes, in your link everything works fine. But online judge for this problem uses ideone where it doesn't work ;(
                              $endgroup$
                              – jean
                              43 mins ago












                            • $begingroup$
                              @jean ideone seems to use -1 as the EOF. +[>,+]<-. should work
                              $endgroup$
                              – Jo King
                              6 mins ago














                            2












                            2








                            2





                            $begingroup$

                            Brainf***, 7 bytes



                            ,[>,]<.





                            share|improve this answer









                            $endgroup$



                            Brainf***, 7 bytes



                            ,[>,]<.






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 2 hours ago









                            SuperJedi224SuperJedi224

                            9,78013363




                            9,78013363












                            • $begingroup$
                              ideone.com/XoJLD0 It still doesn't work ;(
                              $endgroup$
                              – jean
                              53 mins ago










                            • $begingroup$
                              @jean Try it here. (Honestly, I didn't even know ideone did BF).
                              $endgroup$
                              – SuperJedi224
                              49 mins ago












                            • $begingroup$
                              Yes, in your link everything works fine. But online judge for this problem uses ideone where it doesn't work ;(
                              $endgroup$
                              – jean
                              43 mins ago












                            • $begingroup$
                              @jean ideone seems to use -1 as the EOF. +[>,+]<-. should work
                              $endgroup$
                              – Jo King
                              6 mins ago


















                            • $begingroup$
                              ideone.com/XoJLD0 It still doesn't work ;(
                              $endgroup$
                              – jean
                              53 mins ago










                            • $begingroup$
                              @jean Try it here. (Honestly, I didn't even know ideone did BF).
                              $endgroup$
                              – SuperJedi224
                              49 mins ago












                            • $begingroup$
                              Yes, in your link everything works fine. But online judge for this problem uses ideone where it doesn't work ;(
                              $endgroup$
                              – jean
                              43 mins ago












                            • $begingroup$
                              @jean ideone seems to use -1 as the EOF. +[>,+]<-. should work
                              $endgroup$
                              – Jo King
                              6 mins ago
















                            $begingroup$
                            ideone.com/XoJLD0 It still doesn't work ;(
                            $endgroup$
                            – jean
                            53 mins ago




                            $begingroup$
                            ideone.com/XoJLD0 It still doesn't work ;(
                            $endgroup$
                            – jean
                            53 mins ago












                            $begingroup$
                            @jean Try it here. (Honestly, I didn't even know ideone did BF).
                            $endgroup$
                            – SuperJedi224
                            49 mins ago






                            $begingroup$
                            @jean Try it here. (Honestly, I didn't even know ideone did BF).
                            $endgroup$
                            – SuperJedi224
                            49 mins ago














                            $begingroup$
                            Yes, in your link everything works fine. But online judge for this problem uses ideone where it doesn't work ;(
                            $endgroup$
                            – jean
                            43 mins ago






                            $begingroup$
                            Yes, in your link everything works fine. But online judge for this problem uses ideone where it doesn't work ;(
                            $endgroup$
                            – jean
                            43 mins ago














                            $begingroup$
                            @jean ideone seems to use -1 as the EOF. +[>,+]<-. should work
                            $endgroup$
                            – Jo King
                            6 mins ago




                            $begingroup$
                            @jean ideone seems to use -1 as the EOF. +[>,+]<-. should work
                            $endgroup$
                            – Jo King
                            6 mins ago











                            2












                            $begingroup$

                            Javascript, 14 bytes



                            a=>a.slice(-1)





                            share|improve this answer









                            $endgroup$


















                              2












                              $begingroup$

                              Javascript, 14 bytes



                              a=>a.slice(-1)





                              share|improve this answer









                              $endgroup$
















                                2












                                2








                                2





                                $begingroup$

                                Javascript, 14 bytes



                                a=>a.slice(-1)





                                share|improve this answer









                                $endgroup$



                                Javascript, 14 bytes



                                a=>a.slice(-1)






                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered 1 hour ago









                                SuperJedi224SuperJedi224

                                9,78013363




                                9,78013363























                                    2












                                    $begingroup$


                                    Jelly, 1 byte






                                    Try it online!



                                    Not the most difficult challenge in Jelly...






                                    share|improve this answer









                                    $endgroup$


















                                      2












                                      $begingroup$


                                      Jelly, 1 byte






                                      Try it online!



                                      Not the most difficult challenge in Jelly...






                                      share|improve this answer









                                      $endgroup$
















                                        2












                                        2








                                        2





                                        $begingroup$


                                        Jelly, 1 byte






                                        Try it online!



                                        Not the most difficult challenge in Jelly...






                                        share|improve this answer









                                        $endgroup$




                                        Jelly, 1 byte






                                        Try it online!



                                        Not the most difficult challenge in Jelly...







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 57 mins ago









                                        Nick KennedyNick Kennedy

                                        73137




                                        73137























                                            1












                                            $begingroup$


                                            Python 3, 14 bytes





                                            lambda x:x[-1]


                                            Try it online!






                                            share|improve this answer









                                            $endgroup$


















                                              1












                                              $begingroup$


                                              Python 3, 14 bytes





                                              lambda x:x[-1]


                                              Try it online!






                                              share|improve this answer









                                              $endgroup$
















                                                1












                                                1








                                                1





                                                $begingroup$


                                                Python 3, 14 bytes





                                                lambda x:x[-1]


                                                Try it online!






                                                share|improve this answer









                                                $endgroup$




                                                Python 3, 14 bytes





                                                lambda x:x[-1]


                                                Try it online!







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered 1 hour ago









                                                MilkyWay90MilkyWay90

                                                511210




                                                511210























                                                    1












                                                    $begingroup$


                                                    Haskell, 9 bytes





                                                    pure.last


                                                    Try it online!






                                                    share|improve this answer









                                                    $endgroup$


















                                                      1












                                                      $begingroup$


                                                      Haskell, 9 bytes





                                                      pure.last


                                                      Try it online!






                                                      share|improve this answer









                                                      $endgroup$
















                                                        1












                                                        1








                                                        1





                                                        $begingroup$


                                                        Haskell, 9 bytes





                                                        pure.last


                                                        Try it online!






                                                        share|improve this answer









                                                        $endgroup$




                                                        Haskell, 9 bytes





                                                        pure.last


                                                        Try it online!







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered 1 hour ago









                                                        flawrflawr

                                                        26.9k665188




                                                        26.9k665188























                                                            1












                                                            $begingroup$

                                                            PowerShell, 11 bytes



                                                            "$args"[-1]


                                                            Try it online!






                                                            share|improve this answer









                                                            $endgroup$


















                                                              1












                                                              $begingroup$

                                                              PowerShell, 11 bytes



                                                              "$args"[-1]


                                                              Try it online!






                                                              share|improve this answer









                                                              $endgroup$
















                                                                1












                                                                1








                                                                1





                                                                $begingroup$

                                                                PowerShell, 11 bytes



                                                                "$args"[-1]


                                                                Try it online!






                                                                share|improve this answer









                                                                $endgroup$



                                                                PowerShell, 11 bytes



                                                                "$args"[-1]


                                                                Try it online!







                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered 1 hour ago









                                                                Gabriel MillsGabriel Mills

                                                                594213




                                                                594213























                                                                    1












                                                                    $begingroup$


                                                                    Befunge-93, 15 bytes



                                                                    >~# :1+_$$$1-,@


                                                                    Try it online!



                                                                    I bet this could be golfed further, but I'm still trying to get the hang of befunge-93.



                                                                    Alternate 15 byte version that is less messy:



                                                                    ~:1+#v!_
                                                                    @,$<


                                                                    Taking strings as input in Befunge isn't the easiest. If there were a single command to take in multiple characters, it would be as simple as reading the string, popping/printing the top character, and exiting.






                                                                    share|improve this answer











                                                                    $endgroup$













                                                                    • $begingroup$
                                                                      12 bytes
                                                                      $endgroup$
                                                                      – Jo King
                                                                      4 mins ago
















                                                                    1












                                                                    $begingroup$


                                                                    Befunge-93, 15 bytes



                                                                    >~# :1+_$$$1-,@


                                                                    Try it online!



                                                                    I bet this could be golfed further, but I'm still trying to get the hang of befunge-93.



                                                                    Alternate 15 byte version that is less messy:



                                                                    ~:1+#v!_
                                                                    @,$<


                                                                    Taking strings as input in Befunge isn't the easiest. If there were a single command to take in multiple characters, it would be as simple as reading the string, popping/printing the top character, and exiting.






                                                                    share|improve this answer











                                                                    $endgroup$













                                                                    • $begingroup$
                                                                      12 bytes
                                                                      $endgroup$
                                                                      – Jo King
                                                                      4 mins ago














                                                                    1












                                                                    1








                                                                    1





                                                                    $begingroup$


                                                                    Befunge-93, 15 bytes



                                                                    >~# :1+_$$$1-,@


                                                                    Try it online!



                                                                    I bet this could be golfed further, but I'm still trying to get the hang of befunge-93.



                                                                    Alternate 15 byte version that is less messy:



                                                                    ~:1+#v!_
                                                                    @,$<


                                                                    Taking strings as input in Befunge isn't the easiest. If there were a single command to take in multiple characters, it would be as simple as reading the string, popping/printing the top character, and exiting.






                                                                    share|improve this answer











                                                                    $endgroup$




                                                                    Befunge-93, 15 bytes



                                                                    >~# :1+_$$$1-,@


                                                                    Try it online!



                                                                    I bet this could be golfed further, but I'm still trying to get the hang of befunge-93.



                                                                    Alternate 15 byte version that is less messy:



                                                                    ~:1+#v!_
                                                                    @,$<


                                                                    Taking strings as input in Befunge isn't the easiest. If there were a single command to take in multiple characters, it would be as simple as reading the string, popping/printing the top character, and exiting.







                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited 37 mins ago

























                                                                    answered 1 hour ago









                                                                    JPeroutekJPeroutek

                                                                    35018




                                                                    35018












                                                                    • $begingroup$
                                                                      12 bytes
                                                                      $endgroup$
                                                                      – Jo King
                                                                      4 mins ago


















                                                                    • $begingroup$
                                                                      12 bytes
                                                                      $endgroup$
                                                                      – Jo King
                                                                      4 mins ago
















                                                                    $begingroup$
                                                                    12 bytes
                                                                    $endgroup$
                                                                    – Jo King
                                                                    4 mins ago




                                                                    $begingroup$
                                                                    12 bytes
                                                                    $endgroup$
                                                                    – Jo King
                                                                    4 mins ago











                                                                    1












                                                                    $begingroup$

                                                                    MATL, 2 bytes



                                                                    0)


                                                                    MATL uses 1-based modular indexing so this solution grabs the element in the 0-th position of the input which is the same as the last since the 0 wraps around to the end.



                                                                    Try it out at MATL Online






                                                                    share|improve this answer









                                                                    $endgroup$


















                                                                      1












                                                                      $begingroup$

                                                                      MATL, 2 bytes



                                                                      0)


                                                                      MATL uses 1-based modular indexing so this solution grabs the element in the 0-th position of the input which is the same as the last since the 0 wraps around to the end.



                                                                      Try it out at MATL Online






                                                                      share|improve this answer









                                                                      $endgroup$
















                                                                        1












                                                                        1








                                                                        1





                                                                        $begingroup$

                                                                        MATL, 2 bytes



                                                                        0)


                                                                        MATL uses 1-based modular indexing so this solution grabs the element in the 0-th position of the input which is the same as the last since the 0 wraps around to the end.



                                                                        Try it out at MATL Online






                                                                        share|improve this answer









                                                                        $endgroup$



                                                                        MATL, 2 bytes



                                                                        0)


                                                                        MATL uses 1-based modular indexing so this solution grabs the element in the 0-th position of the input which is the same as the last since the 0 wraps around to the end.



                                                                        Try it out at MATL Online







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered 25 mins ago









                                                                        SueverSuever

                                                                        9,7821446




                                                                        9,7821446























                                                                            1












                                                                            $begingroup$


                                                                            Cubix, 6 bytes



                                                                            pA/@po


                                                                            Try it online!



                                                                              p
                                                                            A / @ p
                                                                            o


                                                                            Watch it run





                                                                            • A Takes all the input


                                                                            • / Redirect around the cube


                                                                            • pp bring bottom of the stack to the top twice


                                                                            • o/@ output as character, redirect and halt





                                                                            share









                                                                            $endgroup$


















                                                                              1












                                                                              $begingroup$


                                                                              Cubix, 6 bytes



                                                                              pA/@po


                                                                              Try it online!



                                                                                p
                                                                              A / @ p
                                                                              o


                                                                              Watch it run





                                                                              • A Takes all the input


                                                                              • / Redirect around the cube


                                                                              • pp bring bottom of the stack to the top twice


                                                                              • o/@ output as character, redirect and halt





                                                                              share









                                                                              $endgroup$
















                                                                                1












                                                                                1








                                                                                1





                                                                                $begingroup$


                                                                                Cubix, 6 bytes



                                                                                pA/@po


                                                                                Try it online!



                                                                                  p
                                                                                A / @ p
                                                                                o


                                                                                Watch it run





                                                                                • A Takes all the input


                                                                                • / Redirect around the cube


                                                                                • pp bring bottom of the stack to the top twice


                                                                                • o/@ output as character, redirect and halt





                                                                                share









                                                                                $endgroup$




                                                                                Cubix, 6 bytes



                                                                                pA/@po


                                                                                Try it online!



                                                                                  p
                                                                                A / @ p
                                                                                o


                                                                                Watch it run





                                                                                • A Takes all the input


                                                                                • / Redirect around the cube


                                                                                • pp bring bottom of the stack to the top twice


                                                                                • o/@ output as character, redirect and halt






                                                                                share











                                                                                share


                                                                                share










                                                                                answered 7 mins ago









                                                                                MickyTMickyT

                                                                                10.2k21637




                                                                                10.2k21637























                                                                                    0












                                                                                    $begingroup$

                                                                                    Java 8



                                                                                    Input from STDIN, 71 bytes



                                                                                    v->{int i=0;for(;System.in.available()>0;i=System.in.read());return i;}


                                                                                    Try it online!



                                                                                    Function Argument, 25 bytes



                                                                                    s->s.charAt(s.length()-1)





                                                                                    share|improve this answer











                                                                                    $endgroup$


















                                                                                      0












                                                                                      $begingroup$

                                                                                      Java 8



                                                                                      Input from STDIN, 71 bytes



                                                                                      v->{int i=0;for(;System.in.available()>0;i=System.in.read());return i;}


                                                                                      Try it online!



                                                                                      Function Argument, 25 bytes



                                                                                      s->s.charAt(s.length()-1)





                                                                                      share|improve this answer











                                                                                      $endgroup$
















                                                                                        0












                                                                                        0








                                                                                        0





                                                                                        $begingroup$

                                                                                        Java 8



                                                                                        Input from STDIN, 71 bytes



                                                                                        v->{int i=0;for(;System.in.available()>0;i=System.in.read());return i;}


                                                                                        Try it online!



                                                                                        Function Argument, 25 bytes



                                                                                        s->s.charAt(s.length()-1)





                                                                                        share|improve this answer











                                                                                        $endgroup$



                                                                                        Java 8



                                                                                        Input from STDIN, 71 bytes



                                                                                        v->{int i=0;for(;System.in.available()>0;i=System.in.read());return i;}


                                                                                        Try it online!



                                                                                        Function Argument, 25 bytes



                                                                                        s->s.charAt(s.length()-1)






                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited 1 hour ago

























                                                                                        answered 2 hours ago









                                                                                        Benjamin UrquhartBenjamin Urquhart

                                                                                        1406




                                                                                        1406























                                                                                            0












                                                                                            $begingroup$

                                                                                            TI-BASIC (TI-84), 10 bytes



                                                                                            sub(Ans,length(Ans),1


                                                                                            Gets the last character in the input string.

                                                                                            Input is in Ans.

                                                                                            Output is in Ans and is automatically printed out when the program finishes.






                                                                                            share|improve this answer









                                                                                            $endgroup$


















                                                                                              0












                                                                                              $begingroup$

                                                                                              TI-BASIC (TI-84), 10 bytes



                                                                                              sub(Ans,length(Ans),1


                                                                                              Gets the last character in the input string.

                                                                                              Input is in Ans.

                                                                                              Output is in Ans and is automatically printed out when the program finishes.






                                                                                              share|improve this answer









                                                                                              $endgroup$
















                                                                                                0












                                                                                                0








                                                                                                0





                                                                                                $begingroup$

                                                                                                TI-BASIC (TI-84), 10 bytes



                                                                                                sub(Ans,length(Ans),1


                                                                                                Gets the last character in the input string.

                                                                                                Input is in Ans.

                                                                                                Output is in Ans and is automatically printed out when the program finishes.






                                                                                                share|improve this answer









                                                                                                $endgroup$



                                                                                                TI-BASIC (TI-84), 10 bytes



                                                                                                sub(Ans,length(Ans),1


                                                                                                Gets the last character in the input string.

                                                                                                Input is in Ans.

                                                                                                Output is in Ans and is automatically printed out when the program finishes.







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered 43 mins ago









                                                                                                TauTau

                                                                                                436210




                                                                                                436210























                                                                                                    0












                                                                                                    $begingroup$


                                                                                                    Wolfram Language (Mathematica), 16 bytes



                                                                                                    #~StringTake~-1&


                                                                                                    Try it online!






                                                                                                    share|improve this answer









                                                                                                    $endgroup$


















                                                                                                      0












                                                                                                      $begingroup$


                                                                                                      Wolfram Language (Mathematica), 16 bytes



                                                                                                      #~StringTake~-1&


                                                                                                      Try it online!






                                                                                                      share|improve this answer









                                                                                                      $endgroup$
















                                                                                                        0












                                                                                                        0








                                                                                                        0





                                                                                                        $begingroup$


                                                                                                        Wolfram Language (Mathematica), 16 bytes



                                                                                                        #~StringTake~-1&


                                                                                                        Try it online!






                                                                                                        share|improve this answer









                                                                                                        $endgroup$




                                                                                                        Wolfram Language (Mathematica), 16 bytes



                                                                                                        #~StringTake~-1&


                                                                                                        Try it online!







                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered 41 mins ago









                                                                                                        shrapshrap

                                                                                                        1013




                                                                                                        1013























                                                                                                            0












                                                                                                            $begingroup$


                                                                                                            ><>, 2 bytes



                                                                                                            Using command line args



                                                                                                            o;


                                                                                                            Try it online!




                                                                                                            ><>, 11 bytes



                                                                                                            Using stdin



                                                                                                            ~o;
                                                                                                            /?(0:i


                                                                                                            Try it online!






                                                                                                            share|improve this answer









                                                                                                            $endgroup$


















                                                                                                              0












                                                                                                              $begingroup$


                                                                                                              ><>, 2 bytes



                                                                                                              Using command line args



                                                                                                              o;


                                                                                                              Try it online!




                                                                                                              ><>, 11 bytes



                                                                                                              Using stdin



                                                                                                              ~o;
                                                                                                              /?(0:i


                                                                                                              Try it online!






                                                                                                              share|improve this answer









                                                                                                              $endgroup$
















                                                                                                                0












                                                                                                                0








                                                                                                                0





                                                                                                                $begingroup$


                                                                                                                ><>, 2 bytes



                                                                                                                Using command line args



                                                                                                                o;


                                                                                                                Try it online!




                                                                                                                ><>, 11 bytes



                                                                                                                Using stdin



                                                                                                                ~o;
                                                                                                                /?(0:i


                                                                                                                Try it online!






                                                                                                                share|improve this answer









                                                                                                                $endgroup$




                                                                                                                ><>, 2 bytes



                                                                                                                Using command line args



                                                                                                                o;


                                                                                                                Try it online!




                                                                                                                ><>, 11 bytes



                                                                                                                Using stdin



                                                                                                                ~o;
                                                                                                                /?(0:i


                                                                                                                Try it online!







                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered 12 mins ago









                                                                                                                EmignaEmigna

                                                                                                                47k433142




                                                                                                                47k433142























                                                                                                                    0












                                                                                                                    $begingroup$

                                                                                                                    SmileBASIC, 16 bytes



                                                                                                                    INPUT S$?POP(S$)




                                                                                                                    share









                                                                                                                    $endgroup$


















                                                                                                                      0












                                                                                                                      $begingroup$

                                                                                                                      SmileBASIC, 16 bytes



                                                                                                                      INPUT S$?POP(S$)




                                                                                                                      share









                                                                                                                      $endgroup$
















                                                                                                                        0












                                                                                                                        0








                                                                                                                        0





                                                                                                                        $begingroup$

                                                                                                                        SmileBASIC, 16 bytes



                                                                                                                        INPUT S$?POP(S$)




                                                                                                                        share









                                                                                                                        $endgroup$



                                                                                                                        SmileBASIC, 16 bytes



                                                                                                                        INPUT S$?POP(S$)





                                                                                                                        share











                                                                                                                        share


                                                                                                                        share










                                                                                                                        answered 9 mins ago









                                                                                                                        12Me2112Me21

                                                                                                                        5,61711336




                                                                                                                        5,61711336























                                                                                                                            0












                                                                                                                            $begingroup$


                                                                                                                            05AB1E, 1 byte



                                                                                                                            ¤


                                                                                                                            Try it online!



                                                                                                                            θ or ` would also work.





                                                                                                                            share









                                                                                                                            $endgroup$


















                                                                                                                              0












                                                                                                                              $begingroup$


                                                                                                                              05AB1E, 1 byte



                                                                                                                              ¤


                                                                                                                              Try it online!



                                                                                                                              θ or ` would also work.





                                                                                                                              share









                                                                                                                              $endgroup$
















                                                                                                                                0












                                                                                                                                0








                                                                                                                                0





                                                                                                                                $begingroup$


                                                                                                                                05AB1E, 1 byte



                                                                                                                                ¤


                                                                                                                                Try it online!



                                                                                                                                θ or ` would also work.





                                                                                                                                share









                                                                                                                                $endgroup$




                                                                                                                                05AB1E, 1 byte



                                                                                                                                ¤


                                                                                                                                Try it online!



                                                                                                                                θ or ` would also work.






                                                                                                                                share











                                                                                                                                share


                                                                                                                                share










                                                                                                                                answered 9 mins ago









                                                                                                                                EmignaEmigna

                                                                                                                                47k433142




                                                                                                                                47k433142






















                                                                                                                                    jean is a new contributor. Be nice, and check out our Code of Conduct.










                                                                                                                                    draft saved

                                                                                                                                    draft discarded


















                                                                                                                                    jean is a new contributor. Be nice, and check out our Code of Conduct.













                                                                                                                                    jean is a new contributor. Be nice, and check out our Code of Conduct.












                                                                                                                                    jean is a new contributor. Be nice, and check out our Code of Conduct.
















                                                                                                                                    If this is an answer to a challenge…




                                                                                                                                    • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                    • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                      Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                    • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                                                    More generally…




                                                                                                                                    • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                    • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                                                                                                    draft saved


                                                                                                                                    draft discarded














                                                                                                                                    StackExchange.ready(
                                                                                                                                    function () {
                                                                                                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181627%2fprint-last-inputted-byte%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

                                                                                                                                    Wolfgang Unzicker

                                                                                                                                    Unua mondmilito

                                                                                                                                    Schloss Hohenburg (Lenggries)