Print last inputted byte












9












$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$








  • 4




    $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 days ago






  • 10




    $begingroup$
    I vote against closing; it may be trivial, but that doesn't make it offtopic
    $endgroup$
    – MilkyWay90
    yesterday






  • 1




    $begingroup$
    @MillyWay I think most of the close votes were before the extensive edit by ბიმო
    $endgroup$
    – Sanchises
    yesterday








  • 9




    $begingroup$
    @ბიმო We have a consensus not to edit off-topic questions to make them on-topic which I think would have applied here.
    $endgroup$
    – Laikoni
    yesterday






  • 2




    $begingroup$
    What kind of string? Is it guaranteed to be ASCII only? Or should we handle UTF-8 (and how?) for example?
    $endgroup$
    – FireCubez
    yesterday


















9












$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$








  • 4




    $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 days ago






  • 10




    $begingroup$
    I vote against closing; it may be trivial, but that doesn't make it offtopic
    $endgroup$
    – MilkyWay90
    yesterday






  • 1




    $begingroup$
    @MillyWay I think most of the close votes were before the extensive edit by ბიმო
    $endgroup$
    – Sanchises
    yesterday








  • 9




    $begingroup$
    @ბიმო We have a consensus not to edit off-topic questions to make them on-topic which I think would have applied here.
    $endgroup$
    – Laikoni
    yesterday






  • 2




    $begingroup$
    What kind of string? Is it guaranteed to be ASCII only? Or should we handle UTF-8 (and how?) for example?
    $endgroup$
    – FireCubez
    yesterday
















9












9








9





$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 2 days ago









SuperJedi224

9,86013363




9,86013363






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 2 days ago









jeanjean

643




643




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.








  • 4




    $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 days ago






  • 10




    $begingroup$
    I vote against closing; it may be trivial, but that doesn't make it offtopic
    $endgroup$
    – MilkyWay90
    yesterday






  • 1




    $begingroup$
    @MillyWay I think most of the close votes were before the extensive edit by ბიმო
    $endgroup$
    – Sanchises
    yesterday








  • 9




    $begingroup$
    @ბიმო We have a consensus not to edit off-topic questions to make them on-topic which I think would have applied here.
    $endgroup$
    – Laikoni
    yesterday






  • 2




    $begingroup$
    What kind of string? Is it guaranteed to be ASCII only? Or should we handle UTF-8 (and how?) for example?
    $endgroup$
    – FireCubez
    yesterday
















  • 4




    $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 days ago






  • 10




    $begingroup$
    I vote against closing; it may be trivial, but that doesn't make it offtopic
    $endgroup$
    – MilkyWay90
    yesterday






  • 1




    $begingroup$
    @MillyWay I think most of the close votes were before the extensive edit by ბიმო
    $endgroup$
    – Sanchises
    yesterday








  • 9




    $begingroup$
    @ბიმო We have a consensus not to edit off-topic questions to make them on-topic which I think would have applied here.
    $endgroup$
    – Laikoni
    yesterday






  • 2




    $begingroup$
    What kind of string? Is it guaranteed to be ASCII only? Or should we handle UTF-8 (and how?) for example?
    $endgroup$
    – FireCubez
    yesterday










4




4




$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 days 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 days ago




10




10




$begingroup$
I vote against closing; it may be trivial, but that doesn't make it offtopic
$endgroup$
– MilkyWay90
yesterday




$begingroup$
I vote against closing; it may be trivial, but that doesn't make it offtopic
$endgroup$
– MilkyWay90
yesterday




1




1




$begingroup$
@MillyWay I think most of the close votes were before the extensive edit by ბიმო
$endgroup$
– Sanchises
yesterday






$begingroup$
@MillyWay I think most of the close votes were before the extensive edit by ბიმო
$endgroup$
– Sanchises
yesterday






9




9




$begingroup$
@ბიმო We have a consensus not to edit off-topic questions to make them on-topic which I think would have applied here.
$endgroup$
– Laikoni
yesterday




$begingroup$
@ბიმო We have a consensus not to edit off-topic questions to make them on-topic which I think would have applied here.
$endgroup$
– Laikoni
yesterday




2




2




$begingroup$
What kind of string? Is it guaranteed to be ASCII only? Or should we handle UTF-8 (and how?) for example?
$endgroup$
– FireCubez
yesterday






$begingroup$
What kind of string? Is it guaranteed to be ASCII only? Or should we handle UTF-8 (and how?) for example?
$endgroup$
– FireCubez
yesterday












50 Answers
50






active

oldest

votes













1 2
next












8












$begingroup$


Attache, 4 bytes



Last


Try it online! (If the input could be a list of characters, &/S could work.)



Alternatives



5 bytes: `@&-1



8 bytes: &/S@List



10 bytes: `@«_,-1»



10 bytes: Fold!Right



10 bytes: `@<~_,-1~>



10 bytes: `^^&:Right



10 bytes: {Right^^_}



11 bytes: Get«_,-1»



11 bytes: Get<~_,-1~>



12 bytes: `@«_,#_-1»



12 bytes: `@<~_,#_-1~>



13 bytes: Get«_,#_-1»



13 bytes: Get<~_,#_-1~>






share|improve this answer









$endgroup$









  • 4




    $begingroup$
    :| wtf so many alternatives
    $endgroup$
    – ASCII-only
    yesterday






  • 1




    $begingroup$
    @ASCII-only Least I could do on a simple challenge like this :p
    $endgroup$
    – Conor O'Brien
    yesterday



















7












$begingroup$

Brainf***, 7 bytes



,[>,]<.





share|improve this answer









$endgroup$













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










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












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












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










  • $begingroup$
    @Jo King Sorry, but the input looks like: 29845812674[enter][EOF] how can I print the last digit?
    $endgroup$
    – jean
    yesterday



















7












$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



Explanation



    % Implicitly grab the input
0 % Push the literal 0 to the stack
) % Use this zero to grab the character at the end of the string
% Implicitly display the result





share|improve this answer











$endgroup$













  • $begingroup$
    I'd have gone for J)...
    $endgroup$
    – Sanchises
    yesterday



















7












$begingroup$

x86 Machine Code, 2 bytes



As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.



Input string is in SI, length in CX and output character is in AL:



F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
; loop CX number of times. The last char will be in AL when done.


Or 4 bytes as a "Pascal string" (length is prepended to beginning of string):



AC     LODSB           ; first byte is string length
91 XCHG AX, CX ; move length to CX for loop
F3 AC REPZ LODSB ; start at memory location pointer in SI, put next value in AL,
; loop CX number of times. The last char will be in AL when done.


Or 5 bytes as a "C string" (zero/null terminated), input in DI:



F2 AE     REPNZ SCASB     ; scan for value in AL (0), end when found and advance DI
8A 45 FE MOV AL, [DI-2] ; DI is now two bytes ahead of last, put value of DI-2 into AL


IBM PC DOS, 8088 Assembly, 12 11 bytes



Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.



D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
AC LODSB ; load command line length in AL
91 XCHG AX, CX ; move length to CX for loop
F3/ AC REPZ LODSB ; load next char into AL, repeat until CX = 0
B4 0E MOV AH, 0EH ; PC BIOS write to screen function
CD 10 INT 10H ; display
C3 RET ; exit to DOS


Output:



enter image description here



Download LAST.COM DOS executable (11 bytes)






share|improve this answer











$endgroup$













  • $begingroup$
    Although this certainly gets style points, from a strict golfing point of view, it's worth noting that you are allowed to write functions that return the result in a register. So, this can get a lot shorter. You can trivially eliminate 4 bytes, and a rewrite could shrink it down even further. By the way, is that screenshot from an emulator? Which one?
    $endgroup$
    – Cody Gray
    16 hours ago










  • $begingroup$
    @CodyGray, oh absolutely, the code to take input from command line and output to console is nearly all of it. Yeah, I could say "input string in SI, length in CX output char is in AL" and then I think the only code that would be necessary is REPZ LODSB (2 bytes) and we'd be done. Of course this approach wouldn't be how you do it if you were coding for efficiency, not size. Your point is very well taken though, I'll post it also as a function that does the meat of the work.
    $endgroup$
    – gwaugh
    6 hours ago










  • $begingroup$
    @CodyGray the screenshot is using PCE, which is what I primarily use for testing since it uses the actual PC BIOS ROMs and actual DOS. I build on MASM 1.1 on DOS 2.0. :)
    $endgroup$
    – gwaugh
    6 hours ago



















4












$begingroup$

Javascript, 14 bytes



a=>a.slice(-1)





share|improve this answer









$endgroup$





















    4












    $begingroup$

    Bash + coreutils, 8 bytes



    tail -c1


    Input is from stdin, output is to stdout.






    share|improve this answer









    $endgroup$





















      4












      $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.






      share|improve this answer











      $endgroup$





















        4












        $begingroup$


        Haskell, 9 4 bytes





        last


        Try it online!






        share|improve this answer











        $endgroup$













        • $begingroup$
          Why bother with pure? Isn't last enough?
          $endgroup$
          – dfeuer
          13 hours ago










        • $begingroup$
          I assumed that the output must be a string too, but you're right, OP is only talking about "bytes".
          $endgroup$
          – flawr
          12 hours ago



















        3












        $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$













        • $begingroup$
          You could add the code for program argument to have all three options. :) Too bad OP specifically asks for Strings, otherwise s->s[s.length-1] would have been enough with a char parameter-type.
          $endgroup$
          – Kevin Cruijssen
          yesterday










        • $begingroup$
          61 bytes.
          $endgroup$
          – Olivier Grégoire
          8 hours ago





















        3












        $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$





















          3












          $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|improve this answer









          $endgroup$





















            3












            $begingroup$


            Befunge-93, 12 15 bytes



            :1+_p1-,@>~#


            Try it online!



            Thanks to @Jo King for golfing off 3 bytes.



            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$
              Actually, $$ instead of p1 should work without the warning for the same amount of bytes
              $endgroup$
              – Jo King
              yesterday





















            3












            $begingroup$


            Jelly, 1 byte






            Try it online!



            Not the most difficult challenge in Jelly...



            Note this accepts the input as a string; if the input could be interpreted otherwise (e.g. a number, a list), then it the argument will need to be quoted (e.g. "123456" or "[123,197]"). Alternatively this can be seen as a link that takes a byte array and returns the last member of that array, in accordance with PPCG standard rules.



            Thanks to @MilkyWay90 and @ბიმო for pointing this out.






            share|improve this answer











            $endgroup$













            • $begingroup$
              -1 Fails for any number (tio.run/##y0rNyan8///hzlX///83MTY1NjE1MQYA)
              $endgroup$
              – MilkyWay90
              yesterday










            • $begingroup$
              @MilkyWay90: Doesn't need to be a full program, probably this will work as a Jelly function taking a string. But then again I don't know Jelly, so I might be wrong.
              $endgroup$
              – ბიმო
              yesterday










            • $begingroup$
              Okay, I'll try seeing whether or not it will work as a link
              $endgroup$
              – MilkyWay90
              yesterday










            • $begingroup$
              @ბიმო Seems to work (OP can you edit the answer so I can undo my downvote?)
              $endgroup$
              – MilkyWay90
              yesterday










            • $begingroup$
              You can just define the T as a link and make it input a string, removing the need for "" in your input.
              $endgroup$
              – MilkyWay90
              22 hours ago



















            3












            $begingroup$


            PHP, 13 bytes





            <?=$argn[-1];


            Try it online!



            Run with php -nF input is STDIN. Example:



            $ echo 29845812674|php -nF lost.php





            share|improve this answer









            $endgroup$





















              2












              $begingroup$


              Python 3, 14 bytes





              lambda x:x[-1]


              Try it online!






              share|improve this answer









              $endgroup$





















                2












                $begingroup$

                PowerShell, 11 bytes



                "$args"[-1]


                Try it online!






                share|improve this answer









                $endgroup$





















                  2












                  $begingroup$


                  05AB1E, 1 byte



                  ¤


                  Try it online!



                  θ or ` would also work.






                  share|improve this answer









                  $endgroup$





















                    2












                    $begingroup$

                    Twig, 37 bytes



                    This just uses a simple "extract 1 char from the end and print it" aproach.



                    {%macro a(a)%}{{a[-1:1]}}{%endmacro%}


                    It was really easy to do, and test, but was fun!





                    To use it, you have to put it on a .twig file and import it:



                    {% import 'a.twig' as a %}
                    {{ a.a("string") }} {# should display "g" #}




                    You can test it on https://twigfiddle.com/aa19wd (testcases included)






                    share|improve this answer









                    $endgroup$













                    • $begingroup$
                      Ok, that's the first time I see a Twig golf.
                      $endgroup$
                      – Ven
                      yesterday










                    • $begingroup$
                      @Ven I've been doing it for quite a while. Here's an example: codegolf.stackexchange.com/a/174040 and here's another one: codegolf.stackexchange.com/a/166800 (I have a few more, but well)
                      $endgroup$
                      – Ismael Miguel
                      yesterday



















                    2












                    $begingroup$

                    Python 3, 11 18 34 Bytes



                    import sys;print(sys.argv[-1][-1])


                    Usage via running the program as a python script on the command line. Input is provided as the last argument to the program.



                    Try it online!






                    share|improve this answer










                    New contributor




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






                    $endgroup$













                    • $begingroup$
                      This does not print anything or return anything from a function - snippets are not allowed, only functions or full programs.
                      $endgroup$
                      – Stephen
                      yesterday










                    • $begingroup$
                      Ah I see, didn’t think about that when I though of the answer. Only thought about running it in the interpreter.
                      $endgroup$
                      – Mrwerdo
                      yesterday










                    • $begingroup$
                      This won't handle a newline in the input
                      $endgroup$
                      – Jo King
                      yesterday






                    • 1




                      $begingroup$
                      14
                      $endgroup$
                      – ASCII-only
                      yesterday






                    • 1




                      $begingroup$
                      How about this?
                      $endgroup$
                      – Mrwerdo
                      yesterday



















                    2












                    $begingroup$


                    C# 8.0, 8 bytes



                    Requires .NET Core 3.0, which is in beta. This currently crashes the CLR due to a bug, but once the bug is fixed, this will run as expected and fulfill the challenge requirements.



                    s=>s[^1]




                    C# 8.0, Runs without crashing at time of writing, 22 bytes



                    s=>s.ToCharArray()[^1]




                    C# 8.0, Full Program, 78 bytes



                    using C=System.Console;class A{static void Main(){C.Write(C.ReadLine()[^1]);}}






                    share|improve this answer










                    New contributor




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






                    $endgroup$













                    • $begingroup$
                      The challenge mentions "output", so the last solution is probably the right one
                      $endgroup$
                      – Ven
                      yesterday










                    • $begingroup$
                      Dang, you outdid my console answer by a lot. How does the ^1 work?
                      $endgroup$
                      – Stackstuck
                      yesterday












                    • $begingroup$
                      It's the new Index type. Starting an index with a caret indicates it's from the end, i.e. array[^n] is the same as array[array.Length - n]
                      $endgroup$
                      – briman0094
                      yesterday










                    • $begingroup$
                      Interesting! I always try to stay up to date with new C# features. Do you have any link / reference on that?
                      $endgroup$
                      – mortb
                      12 hours ago






                    • 1




                      $begingroup$
                      Found it: docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0
                      $endgroup$
                      – mortb
                      12 hours ago



















                    1












                    $begingroup$


                    Wolfram Language (Mathematica), 16 bytes



                    #~StringTake~-1&


                    Try it online!






                    share|improve this answer









                    $endgroup$





















                      1












                      $begingroup$


                      Turing Machine But Way Worse, 391 bytes



                      1 0 1 1 0 0 0
                      0 0 0 1 1 0 0
                      1 1 1 1 0 0 0
                      0 1 0 1 2 0 0
                      1 2 1 1 0 0 0
                      0 2 0 1 3 0 0
                      1 3 1 1 0 0 0
                      0 3 0 1 4 0 0
                      1 4 1 1 0 0 0
                      0 4 0 1 5 0 0
                      1 5 1 1 0 0 0
                      0 5 0 1 6 0 0
                      1 6 1 1 0 0 0
                      0 6 0 1 7 0 0
                      1 7 1 1 0 0 0
                      0 7 0 1 8 0 0
                      1 8 1 1 0 0 0
                      0 8 0 0 9 0 0
                      0 9 0 0 a 0 0
                      0 a 0 0 b 0 0
                      0 b 0 0 c 0 0
                      0 c 0 0 d 0 0
                      0 d 0 0 e 0 0
                      0 e 0 0 f 0 0
                      0 f 0 0 h 0 0
                      0 h 0 0 g 0 0
                      0 g 0 0 0 1 1
                      1 g 1 0 0 1 1


                      Try it online!



                      EXPLANATION



                      Detect eight zero bits (which will occur at the end of the input, since TMBWW uses an infinite tape of bits.)
                      1 1 1 1 0 0 0
                      0 1 0 1 2 0 0
                      1 2 1 1 0 0 0
                      0 2 0 1 3 0 0
                      1 3 1 1 0 0 0
                      0 3 0 1 4 0 0
                      1 4 1 1 0 0 0
                      0 4 0 1 5 0 0
                      1 5 1 1 0 0 0
                      0 5 0 1 6 0 0
                      1 6 1 1 0 0 0
                      0 6 0 1 7 0 0
                      1 7 1 1 0 0 0
                      0 7 0 1 8 0 0
                      1 8 1 1 0 0 0
                      0 8 0 0 9 0 0

                      -------------

                      When eight 0 bits are detected, move back to the final byte of the input and print it out while halting the program.
                      0 9 0 0 a 0 0
                      0 a 0 0 b 0 0
                      0 b 0 0 c 0 0
                      0 c 0 0 d 0 0
                      0 d 0 0 e 0 0
                      0 e 0 0 f 0 0
                      0 f 0 0 h 0 0
                      0 h 0 0 g 0 0
                      0 g 0 0 0 1 1
                      1 g 1 0 0 1 1





                      share|improve this answer









                      $endgroup$





















                        1












                        $begingroup$


                        Befunge-98, 5 bytes



                        ~2j@,


                        Try it online!



                        Explanation:



                        ~           Take input
                        2j Skip next two instructions
                        ~ Repeat until EOF, where it reflects
                        @, Print the last character and exit





                        share|improve this answer









                        $endgroup$





















                          1












                          $begingroup$


                          C# (Visual C# Interactive Compiler), 11 bytes





                          x=>x.Last()


                          Try it online!






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            you can use a function :P
                            $endgroup$
                            – ASCII-only
                            yesterday










                          • $begingroup$
                            OK - Ill update my answer :)
                            $endgroup$
                            – dana
                            yesterday






                          • 1




                            $begingroup$
                            uhm why is testcase in STDIN not footer
                            $endgroup$
                            – ASCII-only
                            yesterday










                          • $begingroup$
                            Wow - It's been a while. Thanks for pointing that out ;)
                            $endgroup$
                            – dana
                            yesterday






                          • 1




                            $begingroup$
                            That's not how I understand it. I understand that it should print the last non-empty character. We need to ask OP.
                            $endgroup$
                            – Ven
                            yesterday



















                          1












                          $begingroup$


                          Japt, 1 byte



                          Ì


                          Try it online!



                          -1 byte thanks to Quintec!






                          share|improve this answer











                          $endgroup$









                          • 1




                            $begingroup$
                            1 byte
                            $endgroup$
                            – Quintec
                            yesterday



















                          1












                          $begingroup$

                          APL+WIN, 4 bytes



                          ¯1↑⎕


                          Prompt for input string and select last byte.






                          share|improve this answer









                          $endgroup$





















                            1












                            $begingroup$


                            Whitespace, 54 bytes



                            [N
                            S S N
                            _Create_Label_LOOP][S S S N
                            _Push_0][S N
                            S _Duplicate_0][T N
                            T S _Read_STDIN_as_character][T T T _Retrieve_input][S N
                            S _Duplicate][S S S T S T S N
                            _Push_10][T S S T _Subtract][N
                            T S S N
                            _If_0_Jump_to_Label_PRINT][N
                            S N
                            N
                            _Jump_to_Label_LOOP][N
                            S S S N
                            _Create_Label_PRINT][S N
                            N
                            _Discard_top][T N
                            S S _Print_as_character]


                            Letters S (space), T (tab), and N (new-line) added as highlighting only.
                            [..._some_action] added as explanation only.



                            Since Whitespace can only take input as integer or character, we must add a trailing character to indicate we're done with the input-string after reading it character by character, for which I've used a newline.



                            Try it online (with raw spaces, tabs and new-lines only).



                            Example run: input = A2#



                            Command    Explanation                   Stack                Heap    STDIN STDOUT STDERR

                            NSSN Create Label_LOOP
                            SSSN Push 0 [0]
                            SNS Duplicate top (0) [0,0]
                            TNTS Read STDIN as character [0] {0:65} A
                            TTT Retrieve at heap address (0) [65] {0:65}
                            SNS Duplicate top (65) [65,65] {0:65}
                            SSSTSTSN Push 10 [65,65,10] {0:65}
                            TSST Subtract top two (65-10) [65,55] {0:65}
                            NTSSN If 0: Jump to Label_PRINT [65] {0:65}
                            NSNN Jump to Label_LOOP [65] {0:65}

                            SSSN Push 0 [65,0]
                            SNS Duplicate top (0) [65,0,0]
                            TNTS Read STDIN as character [65,0] {0:50} 2
                            TTT Retrieve at heap address (0) [65,50] {0:50}
                            SNS Duplicate top (50) [65,50,50] {0:50}
                            SSSTSTSN Push 10 [65,50,50,10] {0:50}
                            TSST Subtract top two (50-10) [65,50,40] {0:50}
                            NTSSN If 0: Jump to Label_PRINT [65,50] {0:50}
                            NSNN Jump to Label_LOOP [65,50] {0:50}

                            SSSN Push 0 [65,50,0]
                            SNS Duplicate top (0) [65,50,0,0]
                            TNTS Read STDIN as character [65,50,0] {0:35} #
                            TTT Retrieve at heap address (0) [65,50,35] {0:35}
                            SNS Duplicate top (35) [65,50,35,35] {0:35}
                            SSSTSTSN Push 10 [65,50,35,35,10] {0:35}
                            TSST Subtract top two (35-10) [65,50,35,25] {0:35}
                            NTSSN If 0: Jump to Label_PRINT [65,50,35] {0:35}
                            NSNN Jump to Label_LOOP [65,50,35] {0:35}

                            SSSN Push 0 [65,50,35,0]
                            SNS Duplicate top (0) [65,50,35,0,0]
                            TNTS Read STDIN as character [65,50,35,0] {0:10} n
                            TTT Retrieve at heap address (0) [65,50,35,10] {0:10}
                            SNS Duplicate top (10) [65,50,35,10,10] {0:10}
                            SSSTSTSN Push 10 [65,50,35,10,10,10] {0:10}
                            TSST Subtract top two (10-10) [65,50,35,10,0] {0:10}
                            NTSSN If 0: Jump to Label_PRINT [65,50,35,10] {0:10}

                            NSSSN Create Label_PRINT [65,50,35,10] {0:10}
                            SNN Discard top [65,50,35] {0:10}
                            TNSS Print as character to STDOUT [65,50] {0:10} #
                            {0:10} error


                            Stops with the error: Exit not defined.






                            share|improve this answer









                            $endgroup$





















                              1












                              $begingroup$

                              Turing Machine Code, 72 42 bytes



                              Assumes an input with no empty cells (spaces). Thanks to ASCII-only for saving 30 bytes.



                              0 * * r 1
                              1 * * l 2
                              1 _ _ l halt
                              2 * _ r 0


                              Old version in 72 bytes:



                              0 * * r 0
                              0 _ * l 1
                              1 * * l 2
                              2 * _ l 2
                              2 _ _ r 3
                              3 _ _ r 3
                              3 * * * halt


                              Try it online.






                              share|improve this answer











                              $endgroup$









                              • 1




                                $begingroup$
                                0 * * r 1/1 * * l 2/1 _ _ l halt/2 * _ r 0?
                                $endgroup$
                                – ASCII-only
                                yesterday










                              • $begingroup$
                                oi pls reply :||
                                $endgroup$
                                – ASCII-only
                                yesterday










                              • $begingroup$
                                wouldn't work in what way? I've tested it online
                                $endgroup$
                                – ASCII-only
                                yesterday












                              • $begingroup$
                                @ASCII-only It turns out you're correct, and I was simply misinterpreting the way your program actually worked. I think it's different enough that you can post it as a different answer if you want to.
                                $endgroup$
                                – SuperJedi224
                                yesterday












                              • $begingroup$
                                Well, this is a simple challenge, don't think it needs more than one answer in any language :P
                                $endgroup$
                                – ASCII-only
                                yesterday



















                              1












                              $begingroup$


                              R, 35 bytes



                              Takes the input, splits it in to a list, outputs the last element of the list.





                              tail(strsplit(scan(,''),'')[[1]],1)


                              Try it online!






                              share|improve this answer









                              $endgroup$





















                                1












                                $begingroup$


                                INTERCAL, 270 bytes



                                DO,1<-#1PLEASECOMEFROM(2)DOWRITEIN,1DO.1<-,1SUB#1DO.5<-#1$!1~#256'DO.2<-.3DO(1)NEXTPLEASE.2<-'"!3~#1'$!3~#16'"$"!3~#4'$!3~#64'"'$'"!3~#2'$!3~#32'"$"!3~#8'$!3~#128'"'DO(1010)NEXTPLEASE,1SUB#1<-.3PLEASEREADOUT,1DOGIVEUP(1)DO(1002)NEXTDO(1009)NEXTDO.3<-.3~#255(2)DOFORGET#1


                                Try it online!



                                Writing this was... interesting. I was thinking I might want to use INTERCAL to INTERCALate, but I'm a bit less sure now.



                                Ungolfed and commented:



                                        DO ,1<-#1             PLEASE NOTE We want the input array to only have space for one element, so it will only take one at a time
                                DO COME FROM (2)
                                DO WRITE IN ,1 PLEASE NOTE If this is the first byte of the input, it'll write its value... but if not, it'll write the
                                previous value minus its value mod 256.
                                DO .1<-,1SUB#1
                                DO .5<-#1$!1~#256' PLEASE NOTE .5 is 3 if the input is 256, 2 otherwise
                                DO .2<-.3
                                DO (1) NEXT

                                PLEASE NOTE If we're here, we've found the end of the input. Now, we need to print it back out... C-INTERCAL's
                                array I/O, in order to determine what it will actually print, subtracts the value it's going to print from the
                                previous one (still mod 256, and with the previous value defaulting to 0), and then reads the bits of the byte
                                backwards. So in order to go from the value we want to display to the value we need to feed into READ OUT, we
                                reverse the bits and then subtract from 256. The nightmarish expression on the following line reverses the
                                bits the best way I could think to: individually select each one out and then mingle them all back
                                together. It may be possible to emulate the method used in cesspool.c, by using mingle and unary AND as a
                                substitute for binary AND where we can't afford for select to rearrange it, but it might end up longer...

                                DO .2 <- '"'.3~#1'$'.3~#16'"$"'.3~#4'$'.3~#64'"'$'"'.3~#2'$'.3~#32'"$"'.3~#8'$'.3~#128'"'

                                DO (1010) NEXT PLEASE NOTE .1 already has 256 in it, which is very convenient for when you need to subtract .2 from 256.

                                DO ,1SUB#1 <- .3 PLEASE NOTE If we just read .3 out, we'd get a Roman numeral instead of the correct output.
                                DO READ OUT ,1

                                DO GIVE UP PLEASE NOTE End of program.

                                (1) DO (1002) NEXT PLEASE NOTE that that line in syslib does 1001 next, which pops .5 entries off the next-stack and returns
                                control flow to the last one, such that if .5 is 2 flow will come back here, but if it's 3 then it'll go back
                                to the line that nexted to this one.

                                Here we add .1 and .2 into .3, then truncate it to a byte before looping back (while managing the next-stack
                                responsibly so the program doesn't disappear into the black lagoon for any input over 79 (?) bytes)

                                DO (1009) NEXT
                                DO .3<-.3~#255
                                (2) DO FORGET #1





                                share|improve this answer











                                $endgroup$

















                                  1 2
                                  next



                                  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

























                                  50 Answers
                                  50






                                  active

                                  oldest

                                  votes








                                  50 Answers
                                  50






                                  active

                                  oldest

                                  votes









                                  active

                                  oldest

                                  votes






                                  active

                                  oldest

                                  votes








                                  1 2
                                  next










                                  8












                                  $begingroup$


                                  Attache, 4 bytes



                                  Last


                                  Try it online! (If the input could be a list of characters, &/S could work.)



                                  Alternatives



                                  5 bytes: `@&-1



                                  8 bytes: &/S@List



                                  10 bytes: `@«_,-1»



                                  10 bytes: Fold!Right



                                  10 bytes: `@<~_,-1~>



                                  10 bytes: `^^&:Right



                                  10 bytes: {Right^^_}



                                  11 bytes: Get«_,-1»



                                  11 bytes: Get<~_,-1~>



                                  12 bytes: `@«_,#_-1»



                                  12 bytes: `@<~_,#_-1~>



                                  13 bytes: Get«_,#_-1»



                                  13 bytes: Get<~_,#_-1~>






                                  share|improve this answer









                                  $endgroup$









                                  • 4




                                    $begingroup$
                                    :| wtf so many alternatives
                                    $endgroup$
                                    – ASCII-only
                                    yesterday






                                  • 1




                                    $begingroup$
                                    @ASCII-only Least I could do on a simple challenge like this :p
                                    $endgroup$
                                    – Conor O'Brien
                                    yesterday
















                                  8












                                  $begingroup$


                                  Attache, 4 bytes



                                  Last


                                  Try it online! (If the input could be a list of characters, &/S could work.)



                                  Alternatives



                                  5 bytes: `@&-1



                                  8 bytes: &/S@List



                                  10 bytes: `@«_,-1»



                                  10 bytes: Fold!Right



                                  10 bytes: `@<~_,-1~>



                                  10 bytes: `^^&:Right



                                  10 bytes: {Right^^_}



                                  11 bytes: Get«_,-1»



                                  11 bytes: Get<~_,-1~>



                                  12 bytes: `@«_,#_-1»



                                  12 bytes: `@<~_,#_-1~>



                                  13 bytes: Get«_,#_-1»



                                  13 bytes: Get<~_,#_-1~>






                                  share|improve this answer









                                  $endgroup$









                                  • 4




                                    $begingroup$
                                    :| wtf so many alternatives
                                    $endgroup$
                                    – ASCII-only
                                    yesterday






                                  • 1




                                    $begingroup$
                                    @ASCII-only Least I could do on a simple challenge like this :p
                                    $endgroup$
                                    – Conor O'Brien
                                    yesterday














                                  8












                                  8








                                  8





                                  $begingroup$


                                  Attache, 4 bytes



                                  Last


                                  Try it online! (If the input could be a list of characters, &/S could work.)



                                  Alternatives



                                  5 bytes: `@&-1



                                  8 bytes: &/S@List



                                  10 bytes: `@«_,-1»



                                  10 bytes: Fold!Right



                                  10 bytes: `@<~_,-1~>



                                  10 bytes: `^^&:Right



                                  10 bytes: {Right^^_}



                                  11 bytes: Get«_,-1»



                                  11 bytes: Get<~_,-1~>



                                  12 bytes: `@«_,#_-1»



                                  12 bytes: `@<~_,#_-1~>



                                  13 bytes: Get«_,#_-1»



                                  13 bytes: Get<~_,#_-1~>






                                  share|improve this answer









                                  $endgroup$




                                  Attache, 4 bytes



                                  Last


                                  Try it online! (If the input could be a list of characters, &/S could work.)



                                  Alternatives



                                  5 bytes: `@&-1



                                  8 bytes: &/S@List



                                  10 bytes: `@«_,-1»



                                  10 bytes: Fold!Right



                                  10 bytes: `@<~_,-1~>



                                  10 bytes: `^^&:Right



                                  10 bytes: {Right^^_}



                                  11 bytes: Get«_,-1»



                                  11 bytes: Get<~_,-1~>



                                  12 bytes: `@«_,#_-1»



                                  12 bytes: `@<~_,#_-1~>



                                  13 bytes: Get«_,#_-1»



                                  13 bytes: Get<~_,#_-1~>







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered yesterday









                                  Conor O'BrienConor O'Brien

                                  30.4k264162




                                  30.4k264162








                                  • 4




                                    $begingroup$
                                    :| wtf so many alternatives
                                    $endgroup$
                                    – ASCII-only
                                    yesterday






                                  • 1




                                    $begingroup$
                                    @ASCII-only Least I could do on a simple challenge like this :p
                                    $endgroup$
                                    – Conor O'Brien
                                    yesterday














                                  • 4




                                    $begingroup$
                                    :| wtf so many alternatives
                                    $endgroup$
                                    – ASCII-only
                                    yesterday






                                  • 1




                                    $begingroup$
                                    @ASCII-only Least I could do on a simple challenge like this :p
                                    $endgroup$
                                    – Conor O'Brien
                                    yesterday








                                  4




                                  4




                                  $begingroup$
                                  :| wtf so many alternatives
                                  $endgroup$
                                  – ASCII-only
                                  yesterday




                                  $begingroup$
                                  :| wtf so many alternatives
                                  $endgroup$
                                  – ASCII-only
                                  yesterday




                                  1




                                  1




                                  $begingroup$
                                  @ASCII-only Least I could do on a simple challenge like this :p
                                  $endgroup$
                                  – Conor O'Brien
                                  yesterday




                                  $begingroup$
                                  @ASCII-only Least I could do on a simple challenge like this :p
                                  $endgroup$
                                  – Conor O'Brien
                                  yesterday











                                  7












                                  $begingroup$

                                  Brainf***, 7 bytes



                                  ,[>,]<.





                                  share|improve this answer









                                  $endgroup$













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










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












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












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










                                  • $begingroup$
                                    @Jo King Sorry, but the input looks like: 29845812674[enter][EOF] how can I print the last digit?
                                    $endgroup$
                                    – jean
                                    yesterday
















                                  7












                                  $begingroup$

                                  Brainf***, 7 bytes



                                  ,[>,]<.





                                  share|improve this answer









                                  $endgroup$













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










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












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












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










                                  • $begingroup$
                                    @Jo King Sorry, but the input looks like: 29845812674[enter][EOF] how can I print the last digit?
                                    $endgroup$
                                    – jean
                                    yesterday














                                  7












                                  7








                                  7





                                  $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 days ago









                                  SuperJedi224SuperJedi224

                                  9,86013363




                                  9,86013363












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










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












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












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










                                  • $begingroup$
                                    @Jo King Sorry, but the input looks like: 29845812674[enter][EOF] how can I print the last digit?
                                    $endgroup$
                                    – jean
                                    yesterday


















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










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












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












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










                                  • $begingroup$
                                    @Jo King Sorry, but the input looks like: 29845812674[enter][EOF] how can I print the last digit?
                                    $endgroup$
                                    – jean
                                    yesterday
















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




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












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






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














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






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














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




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












                                  $begingroup$
                                  @Jo King Sorry, but the input looks like: 29845812674[enter][EOF] how can I print the last digit?
                                  $endgroup$
                                  – jean
                                  yesterday




                                  $begingroup$
                                  @Jo King Sorry, but the input looks like: 29845812674[enter][EOF] how can I print the last digit?
                                  $endgroup$
                                  – jean
                                  yesterday











                                  7












                                  $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



                                  Explanation



                                      % Implicitly grab the input
                                  0 % Push the literal 0 to the stack
                                  ) % Use this zero to grab the character at the end of the string
                                  % Implicitly display the result





                                  share|improve this answer











                                  $endgroup$













                                  • $begingroup$
                                    I'd have gone for J)...
                                    $endgroup$
                                    – Sanchises
                                    yesterday
















                                  7












                                  $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



                                  Explanation



                                      % Implicitly grab the input
                                  0 % Push the literal 0 to the stack
                                  ) % Use this zero to grab the character at the end of the string
                                  % Implicitly display the result





                                  share|improve this answer











                                  $endgroup$













                                  • $begingroup$
                                    I'd have gone for J)...
                                    $endgroup$
                                    – Sanchises
                                    yesterday














                                  7












                                  7








                                  7





                                  $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



                                  Explanation



                                      % Implicitly grab the input
                                  0 % Push the literal 0 to the stack
                                  ) % Use this zero to grab the character at the end of the string
                                  % Implicitly display the result





                                  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



                                  Explanation



                                      % Implicitly grab the input
                                  0 % Push the literal 0 to the stack
                                  ) % Use this zero to grab the character at the end of the string
                                  % Implicitly display the result






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited yesterday

























                                  answered 2 days ago









                                  SueverSuever

                                  9,8421446




                                  9,8421446












                                  • $begingroup$
                                    I'd have gone for J)...
                                    $endgroup$
                                    – Sanchises
                                    yesterday


















                                  • $begingroup$
                                    I'd have gone for J)...
                                    $endgroup$
                                    – Sanchises
                                    yesterday
















                                  $begingroup$
                                  I'd have gone for J)...
                                  $endgroup$
                                  – Sanchises
                                  yesterday




                                  $begingroup$
                                  I'd have gone for J)...
                                  $endgroup$
                                  – Sanchises
                                  yesterday











                                  7












                                  $begingroup$

                                  x86 Machine Code, 2 bytes



                                  As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.



                                  Input string is in SI, length in CX and output character is in AL:



                                  F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                                  ; loop CX number of times. The last char will be in AL when done.


                                  Or 4 bytes as a "Pascal string" (length is prepended to beginning of string):



                                  AC     LODSB           ; first byte is string length
                                  91 XCHG AX, CX ; move length to CX for loop
                                  F3 AC REPZ LODSB ; start at memory location pointer in SI, put next value in AL,
                                  ; loop CX number of times. The last char will be in AL when done.


                                  Or 5 bytes as a "C string" (zero/null terminated), input in DI:



                                  F2 AE     REPNZ SCASB     ; scan for value in AL (0), end when found and advance DI
                                  8A 45 FE MOV AL, [DI-2] ; DI is now two bytes ahead of last, put value of DI-2 into AL


                                  IBM PC DOS, 8088 Assembly, 12 11 bytes



                                  Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.



                                  D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
                                  AC LODSB ; load command line length in AL
                                  91 XCHG AX, CX ; move length to CX for loop
                                  F3/ AC REPZ LODSB ; load next char into AL, repeat until CX = 0
                                  B4 0E MOV AH, 0EH ; PC BIOS write to screen function
                                  CD 10 INT 10H ; display
                                  C3 RET ; exit to DOS


                                  Output:



                                  enter image description here



                                  Download LAST.COM DOS executable (11 bytes)






                                  share|improve this answer











                                  $endgroup$













                                  • $begingroup$
                                    Although this certainly gets style points, from a strict golfing point of view, it's worth noting that you are allowed to write functions that return the result in a register. So, this can get a lot shorter. You can trivially eliminate 4 bytes, and a rewrite could shrink it down even further. By the way, is that screenshot from an emulator? Which one?
                                    $endgroup$
                                    – Cody Gray
                                    16 hours ago










                                  • $begingroup$
                                    @CodyGray, oh absolutely, the code to take input from command line and output to console is nearly all of it. Yeah, I could say "input string in SI, length in CX output char is in AL" and then I think the only code that would be necessary is REPZ LODSB (2 bytes) and we'd be done. Of course this approach wouldn't be how you do it if you were coding for efficiency, not size. Your point is very well taken though, I'll post it also as a function that does the meat of the work.
                                    $endgroup$
                                    – gwaugh
                                    6 hours ago










                                  • $begingroup$
                                    @CodyGray the screenshot is using PCE, which is what I primarily use for testing since it uses the actual PC BIOS ROMs and actual DOS. I build on MASM 1.1 on DOS 2.0. :)
                                    $endgroup$
                                    – gwaugh
                                    6 hours ago
















                                  7












                                  $begingroup$

                                  x86 Machine Code, 2 bytes



                                  As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.



                                  Input string is in SI, length in CX and output character is in AL:



                                  F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                                  ; loop CX number of times. The last char will be in AL when done.


                                  Or 4 bytes as a "Pascal string" (length is prepended to beginning of string):



                                  AC     LODSB           ; first byte is string length
                                  91 XCHG AX, CX ; move length to CX for loop
                                  F3 AC REPZ LODSB ; start at memory location pointer in SI, put next value in AL,
                                  ; loop CX number of times. The last char will be in AL when done.


                                  Or 5 bytes as a "C string" (zero/null terminated), input in DI:



                                  F2 AE     REPNZ SCASB     ; scan for value in AL (0), end when found and advance DI
                                  8A 45 FE MOV AL, [DI-2] ; DI is now two bytes ahead of last, put value of DI-2 into AL


                                  IBM PC DOS, 8088 Assembly, 12 11 bytes



                                  Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.



                                  D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
                                  AC LODSB ; load command line length in AL
                                  91 XCHG AX, CX ; move length to CX for loop
                                  F3/ AC REPZ LODSB ; load next char into AL, repeat until CX = 0
                                  B4 0E MOV AH, 0EH ; PC BIOS write to screen function
                                  CD 10 INT 10H ; display
                                  C3 RET ; exit to DOS


                                  Output:



                                  enter image description here



                                  Download LAST.COM DOS executable (11 bytes)






                                  share|improve this answer











                                  $endgroup$













                                  • $begingroup$
                                    Although this certainly gets style points, from a strict golfing point of view, it's worth noting that you are allowed to write functions that return the result in a register. So, this can get a lot shorter. You can trivially eliminate 4 bytes, and a rewrite could shrink it down even further. By the way, is that screenshot from an emulator? Which one?
                                    $endgroup$
                                    – Cody Gray
                                    16 hours ago










                                  • $begingroup$
                                    @CodyGray, oh absolutely, the code to take input from command line and output to console is nearly all of it. Yeah, I could say "input string in SI, length in CX output char is in AL" and then I think the only code that would be necessary is REPZ LODSB (2 bytes) and we'd be done. Of course this approach wouldn't be how you do it if you were coding for efficiency, not size. Your point is very well taken though, I'll post it also as a function that does the meat of the work.
                                    $endgroup$
                                    – gwaugh
                                    6 hours ago










                                  • $begingroup$
                                    @CodyGray the screenshot is using PCE, which is what I primarily use for testing since it uses the actual PC BIOS ROMs and actual DOS. I build on MASM 1.1 on DOS 2.0. :)
                                    $endgroup$
                                    – gwaugh
                                    6 hours ago














                                  7












                                  7








                                  7





                                  $begingroup$

                                  x86 Machine Code, 2 bytes



                                  As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.



                                  Input string is in SI, length in CX and output character is in AL:



                                  F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                                  ; loop CX number of times. The last char will be in AL when done.


                                  Or 4 bytes as a "Pascal string" (length is prepended to beginning of string):



                                  AC     LODSB           ; first byte is string length
                                  91 XCHG AX, CX ; move length to CX for loop
                                  F3 AC REPZ LODSB ; start at memory location pointer in SI, put next value in AL,
                                  ; loop CX number of times. The last char will be in AL when done.


                                  Or 5 bytes as a "C string" (zero/null terminated), input in DI:



                                  F2 AE     REPNZ SCASB     ; scan for value in AL (0), end when found and advance DI
                                  8A 45 FE MOV AL, [DI-2] ; DI is now two bytes ahead of last, put value of DI-2 into AL


                                  IBM PC DOS, 8088 Assembly, 12 11 bytes



                                  Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.



                                  D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
                                  AC LODSB ; load command line length in AL
                                  91 XCHG AX, CX ; move length to CX for loop
                                  F3/ AC REPZ LODSB ; load next char into AL, repeat until CX = 0
                                  B4 0E MOV AH, 0EH ; PC BIOS write to screen function
                                  CD 10 INT 10H ; display
                                  C3 RET ; exit to DOS


                                  Output:



                                  enter image description here



                                  Download LAST.COM DOS executable (11 bytes)






                                  share|improve this answer











                                  $endgroup$



                                  x86 Machine Code, 2 bytes



                                  As @CodyGray correctly points out, taking input as a string and output to a register removes the bulk of the standalone program version.



                                  Input string is in SI, length in CX and output character is in AL:



                                  F3 AC  REPZ LODSB      ; start at memory location pointer in SI, put next value in AL,
                                  ; loop CX number of times. The last char will be in AL when done.


                                  Or 4 bytes as a "Pascal string" (length is prepended to beginning of string):



                                  AC     LODSB           ; first byte is string length
                                  91 XCHG AX, CX ; move length to CX for loop
                                  F3 AC REPZ LODSB ; start at memory location pointer in SI, put next value in AL,
                                  ; loop CX number of times. The last char will be in AL when done.


                                  Or 5 bytes as a "C string" (zero/null terminated), input in DI:



                                  F2 AE     REPNZ SCASB     ; scan for value in AL (0), end when found and advance DI
                                  8A 45 FE MOV AL, [DI-2] ; DI is now two bytes ahead of last, put value of DI-2 into AL


                                  IBM PC DOS, 8088 Assembly, 12 11 bytes



                                  Or as complete program as IBM PC DOS executable. Input is from command line, output is to console.



                                  D1 EE   SHR  SI, 1      ; SI to DOS PSP at 80H (SI is 0100H at runtime) 
                                  AC LODSB ; load command line length in AL
                                  91 XCHG AX, CX ; move length to CX for loop
                                  F3/ AC REPZ LODSB ; load next char into AL, repeat until CX = 0
                                  B4 0E MOV AH, 0EH ; PC BIOS write to screen function
                                  CD 10 INT 10H ; display
                                  C3 RET ; exit to DOS


                                  Output:



                                  enter image description here



                                  Download LAST.COM DOS executable (11 bytes)







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited 5 hours ago

























                                  answered yesterday









                                  gwaughgwaugh

                                  1,838515




                                  1,838515












                                  • $begingroup$
                                    Although this certainly gets style points, from a strict golfing point of view, it's worth noting that you are allowed to write functions that return the result in a register. So, this can get a lot shorter. You can trivially eliminate 4 bytes, and a rewrite could shrink it down even further. By the way, is that screenshot from an emulator? Which one?
                                    $endgroup$
                                    – Cody Gray
                                    16 hours ago










                                  • $begingroup$
                                    @CodyGray, oh absolutely, the code to take input from command line and output to console is nearly all of it. Yeah, I could say "input string in SI, length in CX output char is in AL" and then I think the only code that would be necessary is REPZ LODSB (2 bytes) and we'd be done. Of course this approach wouldn't be how you do it if you were coding for efficiency, not size. Your point is very well taken though, I'll post it also as a function that does the meat of the work.
                                    $endgroup$
                                    – gwaugh
                                    6 hours ago










                                  • $begingroup$
                                    @CodyGray the screenshot is using PCE, which is what I primarily use for testing since it uses the actual PC BIOS ROMs and actual DOS. I build on MASM 1.1 on DOS 2.0. :)
                                    $endgroup$
                                    – gwaugh
                                    6 hours ago


















                                  • $begingroup$
                                    Although this certainly gets style points, from a strict golfing point of view, it's worth noting that you are allowed to write functions that return the result in a register. So, this can get a lot shorter. You can trivially eliminate 4 bytes, and a rewrite could shrink it down even further. By the way, is that screenshot from an emulator? Which one?
                                    $endgroup$
                                    – Cody Gray
                                    16 hours ago










                                  • $begingroup$
                                    @CodyGray, oh absolutely, the code to take input from command line and output to console is nearly all of it. Yeah, I could say "input string in SI, length in CX output char is in AL" and then I think the only code that would be necessary is REPZ LODSB (2 bytes) and we'd be done. Of course this approach wouldn't be how you do it if you were coding for efficiency, not size. Your point is very well taken though, I'll post it also as a function that does the meat of the work.
                                    $endgroup$
                                    – gwaugh
                                    6 hours ago










                                  • $begingroup$
                                    @CodyGray the screenshot is using PCE, which is what I primarily use for testing since it uses the actual PC BIOS ROMs and actual DOS. I build on MASM 1.1 on DOS 2.0. :)
                                    $endgroup$
                                    – gwaugh
                                    6 hours ago
















                                  $begingroup$
                                  Although this certainly gets style points, from a strict golfing point of view, it's worth noting that you are allowed to write functions that return the result in a register. So, this can get a lot shorter. You can trivially eliminate 4 bytes, and a rewrite could shrink it down even further. By the way, is that screenshot from an emulator? Which one?
                                  $endgroup$
                                  – Cody Gray
                                  16 hours ago




                                  $begingroup$
                                  Although this certainly gets style points, from a strict golfing point of view, it's worth noting that you are allowed to write functions that return the result in a register. So, this can get a lot shorter. You can trivially eliminate 4 bytes, and a rewrite could shrink it down even further. By the way, is that screenshot from an emulator? Which one?
                                  $endgroup$
                                  – Cody Gray
                                  16 hours ago












                                  $begingroup$
                                  @CodyGray, oh absolutely, the code to take input from command line and output to console is nearly all of it. Yeah, I could say "input string in SI, length in CX output char is in AL" and then I think the only code that would be necessary is REPZ LODSB (2 bytes) and we'd be done. Of course this approach wouldn't be how you do it if you were coding for efficiency, not size. Your point is very well taken though, I'll post it also as a function that does the meat of the work.
                                  $endgroup$
                                  – gwaugh
                                  6 hours ago




                                  $begingroup$
                                  @CodyGray, oh absolutely, the code to take input from command line and output to console is nearly all of it. Yeah, I could say "input string in SI, length in CX output char is in AL" and then I think the only code that would be necessary is REPZ LODSB (2 bytes) and we'd be done. Of course this approach wouldn't be how you do it if you were coding for efficiency, not size. Your point is very well taken though, I'll post it also as a function that does the meat of the work.
                                  $endgroup$
                                  – gwaugh
                                  6 hours ago












                                  $begingroup$
                                  @CodyGray the screenshot is using PCE, which is what I primarily use for testing since it uses the actual PC BIOS ROMs and actual DOS. I build on MASM 1.1 on DOS 2.0. :)
                                  $endgroup$
                                  – gwaugh
                                  6 hours ago




                                  $begingroup$
                                  @CodyGray the screenshot is using PCE, which is what I primarily use for testing since it uses the actual PC BIOS ROMs and actual DOS. I build on MASM 1.1 on DOS 2.0. :)
                                  $endgroup$
                                  – gwaugh
                                  6 hours ago











                                  4












                                  $begingroup$

                                  Javascript, 14 bytes



                                  a=>a.slice(-1)





                                  share|improve this answer









                                  $endgroup$


















                                    4












                                    $begingroup$

                                    Javascript, 14 bytes



                                    a=>a.slice(-1)





                                    share|improve this answer









                                    $endgroup$
















                                      4












                                      4








                                      4





                                      $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 2 days ago









                                      SuperJedi224SuperJedi224

                                      9,86013363




                                      9,86013363























                                          4












                                          $begingroup$

                                          Bash + coreutils, 8 bytes



                                          tail -c1


                                          Input is from stdin, output is to stdout.






                                          share|improve this answer









                                          $endgroup$


















                                            4












                                            $begingroup$

                                            Bash + coreutils, 8 bytes



                                            tail -c1


                                            Input is from stdin, output is to stdout.






                                            share|improve this answer









                                            $endgroup$
















                                              4












                                              4








                                              4





                                              $begingroup$

                                              Bash + coreutils, 8 bytes



                                              tail -c1


                                              Input is from stdin, output is to stdout.






                                              share|improve this answer









                                              $endgroup$



                                              Bash + coreutils, 8 bytes



                                              tail -c1


                                              Input is from stdin, output is to stdout.







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered yesterday









                                              pizzapants184pizzapants184

                                              2,764716




                                              2,764716























                                                  4












                                                  $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.






                                                  share|improve this answer











                                                  $endgroup$


















                                                    4












                                                    $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.






                                                    share|improve this answer











                                                    $endgroup$
















                                                      4












                                                      4








                                                      4





                                                      $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.






                                                      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.







                                                      share|improve this answer














                                                      share|improve this answer



                                                      share|improve this answer








                                                      edited yesterday

























                                                      answered 2 days ago









                                                      TauTau

                                                      496210




                                                      496210























                                                          4












                                                          $begingroup$


                                                          Haskell, 9 4 bytes





                                                          last


                                                          Try it online!






                                                          share|improve this answer











                                                          $endgroup$













                                                          • $begingroup$
                                                            Why bother with pure? Isn't last enough?
                                                            $endgroup$
                                                            – dfeuer
                                                            13 hours ago










                                                          • $begingroup$
                                                            I assumed that the output must be a string too, but you're right, OP is only talking about "bytes".
                                                            $endgroup$
                                                            – flawr
                                                            12 hours ago
















                                                          4












                                                          $begingroup$


                                                          Haskell, 9 4 bytes





                                                          last


                                                          Try it online!






                                                          share|improve this answer











                                                          $endgroup$













                                                          • $begingroup$
                                                            Why bother with pure? Isn't last enough?
                                                            $endgroup$
                                                            – dfeuer
                                                            13 hours ago










                                                          • $begingroup$
                                                            I assumed that the output must be a string too, but you're right, OP is only talking about "bytes".
                                                            $endgroup$
                                                            – flawr
                                                            12 hours ago














                                                          4












                                                          4








                                                          4





                                                          $begingroup$


                                                          Haskell, 9 4 bytes





                                                          last


                                                          Try it online!






                                                          share|improve this answer











                                                          $endgroup$




                                                          Haskell, 9 4 bytes





                                                          last


                                                          Try it online!







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited 12 hours ago

























                                                          answered 2 days ago









                                                          flawrflawr

                                                          26.9k665188




                                                          26.9k665188












                                                          • $begingroup$
                                                            Why bother with pure? Isn't last enough?
                                                            $endgroup$
                                                            – dfeuer
                                                            13 hours ago










                                                          • $begingroup$
                                                            I assumed that the output must be a string too, but you're right, OP is only talking about "bytes".
                                                            $endgroup$
                                                            – flawr
                                                            12 hours ago


















                                                          • $begingroup$
                                                            Why bother with pure? Isn't last enough?
                                                            $endgroup$
                                                            – dfeuer
                                                            13 hours ago










                                                          • $begingroup$
                                                            I assumed that the output must be a string too, but you're right, OP is only talking about "bytes".
                                                            $endgroup$
                                                            – flawr
                                                            12 hours ago
















                                                          $begingroup$
                                                          Why bother with pure? Isn't last enough?
                                                          $endgroup$
                                                          – dfeuer
                                                          13 hours ago




                                                          $begingroup$
                                                          Why bother with pure? Isn't last enough?
                                                          $endgroup$
                                                          – dfeuer
                                                          13 hours ago












                                                          $begingroup$
                                                          I assumed that the output must be a string too, but you're right, OP is only talking about "bytes".
                                                          $endgroup$
                                                          – flawr
                                                          12 hours ago




                                                          $begingroup$
                                                          I assumed that the output must be a string too, but you're right, OP is only talking about "bytes".
                                                          $endgroup$
                                                          – flawr
                                                          12 hours ago











                                                          3












                                                          $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$













                                                          • $begingroup$
                                                            You could add the code for program argument to have all three options. :) Too bad OP specifically asks for Strings, otherwise s->s[s.length-1] would have been enough with a char parameter-type.
                                                            $endgroup$
                                                            – Kevin Cruijssen
                                                            yesterday










                                                          • $begingroup$
                                                            61 bytes.
                                                            $endgroup$
                                                            – Olivier Grégoire
                                                            8 hours ago


















                                                          3












                                                          $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$













                                                          • $begingroup$
                                                            You could add the code for program argument to have all three options. :) Too bad OP specifically asks for Strings, otherwise s->s[s.length-1] would have been enough with a char parameter-type.
                                                            $endgroup$
                                                            – Kevin Cruijssen
                                                            yesterday










                                                          • $begingroup$
                                                            61 bytes.
                                                            $endgroup$
                                                            – Olivier Grégoire
                                                            8 hours ago
















                                                          3












                                                          3








                                                          3





                                                          $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 2 days ago

























                                                          answered 2 days ago









                                                          Benjamin UrquhartBenjamin Urquhart

                                                          3057




                                                          3057












                                                          • $begingroup$
                                                            You could add the code for program argument to have all three options. :) Too bad OP specifically asks for Strings, otherwise s->s[s.length-1] would have been enough with a char parameter-type.
                                                            $endgroup$
                                                            – Kevin Cruijssen
                                                            yesterday










                                                          • $begingroup$
                                                            61 bytes.
                                                            $endgroup$
                                                            – Olivier Grégoire
                                                            8 hours ago




















                                                          • $begingroup$
                                                            You could add the code for program argument to have all three options. :) Too bad OP specifically asks for Strings, otherwise s->s[s.length-1] would have been enough with a char parameter-type.
                                                            $endgroup$
                                                            – Kevin Cruijssen
                                                            yesterday










                                                          • $begingroup$
                                                            61 bytes.
                                                            $endgroup$
                                                            – Olivier Grégoire
                                                            8 hours ago


















                                                          $begingroup$
                                                          You could add the code for program argument to have all three options. :) Too bad OP specifically asks for Strings, otherwise s->s[s.length-1] would have been enough with a char parameter-type.
                                                          $endgroup$
                                                          – Kevin Cruijssen
                                                          yesterday




                                                          $begingroup$
                                                          You could add the code for program argument to have all three options. :) Too bad OP specifically asks for Strings, otherwise s->s[s.length-1] would have been enough with a char parameter-type.
                                                          $endgroup$
                                                          – Kevin Cruijssen
                                                          yesterday












                                                          $begingroup$
                                                          61 bytes.
                                                          $endgroup$
                                                          – Olivier Grégoire
                                                          8 hours ago






                                                          $begingroup$
                                                          61 bytes.
                                                          $endgroup$
                                                          – Olivier Grégoire
                                                          8 hours ago













                                                          3












                                                          $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$


















                                                            3












                                                            $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$
















                                                              3












                                                              3








                                                              3





                                                              $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 2 days ago









                                                              EmignaEmigna

                                                              47k433142




                                                              47k433142























                                                                  3












                                                                  $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|improve this answer









                                                                  $endgroup$


















                                                                    3












                                                                    $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|improve this answer









                                                                    $endgroup$
















                                                                      3












                                                                      3








                                                                      3





                                                                      $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|improve this answer









                                                                      $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|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered yesterday









                                                                      MickyTMickyT

                                                                      10.2k21637




                                                                      10.2k21637























                                                                          3












                                                                          $begingroup$


                                                                          Befunge-93, 12 15 bytes



                                                                          :1+_p1-,@>~#


                                                                          Try it online!



                                                                          Thanks to @Jo King for golfing off 3 bytes.



                                                                          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$
                                                                            Actually, $$ instead of p1 should work without the warning for the same amount of bytes
                                                                            $endgroup$
                                                                            – Jo King
                                                                            yesterday


















                                                                          3












                                                                          $begingroup$


                                                                          Befunge-93, 12 15 bytes



                                                                          :1+_p1-,@>~#


                                                                          Try it online!



                                                                          Thanks to @Jo King for golfing off 3 bytes.



                                                                          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$
                                                                            Actually, $$ instead of p1 should work without the warning for the same amount of bytes
                                                                            $endgroup$
                                                                            – Jo King
                                                                            yesterday
















                                                                          3












                                                                          3








                                                                          3





                                                                          $begingroup$


                                                                          Befunge-93, 12 15 bytes



                                                                          :1+_p1-,@>~#


                                                                          Try it online!



                                                                          Thanks to @Jo King for golfing off 3 bytes.



                                                                          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, 12 15 bytes



                                                                          :1+_p1-,@>~#


                                                                          Try it online!



                                                                          Thanks to @Jo King for golfing off 3 bytes.



                                                                          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 yesterday

























                                                                          answered 2 days ago









                                                                          JPeroutekJPeroutek

                                                                          37018




                                                                          37018












                                                                          • $begingroup$
                                                                            Actually, $$ instead of p1 should work without the warning for the same amount of bytes
                                                                            $endgroup$
                                                                            – Jo King
                                                                            yesterday




















                                                                          • $begingroup$
                                                                            Actually, $$ instead of p1 should work without the warning for the same amount of bytes
                                                                            $endgroup$
                                                                            – Jo King
                                                                            yesterday


















                                                                          $begingroup$
                                                                          Actually, $$ instead of p1 should work without the warning for the same amount of bytes
                                                                          $endgroup$
                                                                          – Jo King
                                                                          yesterday






                                                                          $begingroup$
                                                                          Actually, $$ instead of p1 should work without the warning for the same amount of bytes
                                                                          $endgroup$
                                                                          – Jo King
                                                                          yesterday













                                                                          3












                                                                          $begingroup$


                                                                          Jelly, 1 byte






                                                                          Try it online!



                                                                          Not the most difficult challenge in Jelly...



                                                                          Note this accepts the input as a string; if the input could be interpreted otherwise (e.g. a number, a list), then it the argument will need to be quoted (e.g. "123456" or "[123,197]"). Alternatively this can be seen as a link that takes a byte array and returns the last member of that array, in accordance with PPCG standard rules.



                                                                          Thanks to @MilkyWay90 and @ბიმო for pointing this out.






                                                                          share|improve this answer











                                                                          $endgroup$













                                                                          • $begingroup$
                                                                            -1 Fails for any number (tio.run/##y0rNyan8///hzlX///83MTY1NjE1MQYA)
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            @MilkyWay90: Doesn't need to be a full program, probably this will work as a Jelly function taking a string. But then again I don't know Jelly, so I might be wrong.
                                                                            $endgroup$
                                                                            – ბიმო
                                                                            yesterday










                                                                          • $begingroup$
                                                                            Okay, I'll try seeing whether or not it will work as a link
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            @ბიმო Seems to work (OP can you edit the answer so I can undo my downvote?)
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            You can just define the T as a link and make it input a string, removing the need for "" in your input.
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            22 hours ago
















                                                                          3












                                                                          $begingroup$


                                                                          Jelly, 1 byte






                                                                          Try it online!



                                                                          Not the most difficult challenge in Jelly...



                                                                          Note this accepts the input as a string; if the input could be interpreted otherwise (e.g. a number, a list), then it the argument will need to be quoted (e.g. "123456" or "[123,197]"). Alternatively this can be seen as a link that takes a byte array and returns the last member of that array, in accordance with PPCG standard rules.



                                                                          Thanks to @MilkyWay90 and @ბიმო for pointing this out.






                                                                          share|improve this answer











                                                                          $endgroup$













                                                                          • $begingroup$
                                                                            -1 Fails for any number (tio.run/##y0rNyan8///hzlX///83MTY1NjE1MQYA)
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            @MilkyWay90: Doesn't need to be a full program, probably this will work as a Jelly function taking a string. But then again I don't know Jelly, so I might be wrong.
                                                                            $endgroup$
                                                                            – ბიმო
                                                                            yesterday










                                                                          • $begingroup$
                                                                            Okay, I'll try seeing whether or not it will work as a link
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            @ბიმო Seems to work (OP can you edit the answer so I can undo my downvote?)
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            You can just define the T as a link and make it input a string, removing the need for "" in your input.
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            22 hours ago














                                                                          3












                                                                          3








                                                                          3





                                                                          $begingroup$


                                                                          Jelly, 1 byte






                                                                          Try it online!



                                                                          Not the most difficult challenge in Jelly...



                                                                          Note this accepts the input as a string; if the input could be interpreted otherwise (e.g. a number, a list), then it the argument will need to be quoted (e.g. "123456" or "[123,197]"). Alternatively this can be seen as a link that takes a byte array and returns the last member of that array, in accordance with PPCG standard rules.



                                                                          Thanks to @MilkyWay90 and @ბიმო for pointing this out.






                                                                          share|improve this answer











                                                                          $endgroup$




                                                                          Jelly, 1 byte






                                                                          Try it online!



                                                                          Not the most difficult challenge in Jelly...



                                                                          Note this accepts the input as a string; if the input could be interpreted otherwise (e.g. a number, a list), then it the argument will need to be quoted (e.g. "123456" or "[123,197]"). Alternatively this can be seen as a link that takes a byte array and returns the last member of that array, in accordance with PPCG standard rules.



                                                                          Thanks to @MilkyWay90 and @ბიმო for pointing this out.







                                                                          share|improve this answer














                                                                          share|improve this answer



                                                                          share|improve this answer








                                                                          edited yesterday

























                                                                          answered 2 days ago









                                                                          Nick KennedyNick Kennedy

                                                                          78137




                                                                          78137












                                                                          • $begingroup$
                                                                            -1 Fails for any number (tio.run/##y0rNyan8///hzlX///83MTY1NjE1MQYA)
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            @MilkyWay90: Doesn't need to be a full program, probably this will work as a Jelly function taking a string. But then again I don't know Jelly, so I might be wrong.
                                                                            $endgroup$
                                                                            – ბიმო
                                                                            yesterday










                                                                          • $begingroup$
                                                                            Okay, I'll try seeing whether or not it will work as a link
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            @ბიმო Seems to work (OP can you edit the answer so I can undo my downvote?)
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            You can just define the T as a link and make it input a string, removing the need for "" in your input.
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            22 hours ago


















                                                                          • $begingroup$
                                                                            -1 Fails for any number (tio.run/##y0rNyan8///hzlX///83MTY1NjE1MQYA)
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            @MilkyWay90: Doesn't need to be a full program, probably this will work as a Jelly function taking a string. But then again I don't know Jelly, so I might be wrong.
                                                                            $endgroup$
                                                                            – ბიმო
                                                                            yesterday










                                                                          • $begingroup$
                                                                            Okay, I'll try seeing whether or not it will work as a link
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            @ბიმო Seems to work (OP can you edit the answer so I can undo my downvote?)
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            yesterday










                                                                          • $begingroup$
                                                                            You can just define the T as a link and make it input a string, removing the need for "" in your input.
                                                                            $endgroup$
                                                                            – MilkyWay90
                                                                            22 hours ago
















                                                                          $begingroup$
                                                                          -1 Fails for any number (tio.run/##y0rNyan8///hzlX///83MTY1NjE1MQYA)
                                                                          $endgroup$
                                                                          – MilkyWay90
                                                                          yesterday




                                                                          $begingroup$
                                                                          -1 Fails for any number (tio.run/##y0rNyan8///hzlX///83MTY1NjE1MQYA)
                                                                          $endgroup$
                                                                          – MilkyWay90
                                                                          yesterday












                                                                          $begingroup$
                                                                          @MilkyWay90: Doesn't need to be a full program, probably this will work as a Jelly function taking a string. But then again I don't know Jelly, so I might be wrong.
                                                                          $endgroup$
                                                                          – ბიმო
                                                                          yesterday




                                                                          $begingroup$
                                                                          @MilkyWay90: Doesn't need to be a full program, probably this will work as a Jelly function taking a string. But then again I don't know Jelly, so I might be wrong.
                                                                          $endgroup$
                                                                          – ბიმო
                                                                          yesterday












                                                                          $begingroup$
                                                                          Okay, I'll try seeing whether or not it will work as a link
                                                                          $endgroup$
                                                                          – MilkyWay90
                                                                          yesterday




                                                                          $begingroup$
                                                                          Okay, I'll try seeing whether or not it will work as a link
                                                                          $endgroup$
                                                                          – MilkyWay90
                                                                          yesterday












                                                                          $begingroup$
                                                                          @ბიმო Seems to work (OP can you edit the answer so I can undo my downvote?)
                                                                          $endgroup$
                                                                          – MilkyWay90
                                                                          yesterday




                                                                          $begingroup$
                                                                          @ბიმო Seems to work (OP can you edit the answer so I can undo my downvote?)
                                                                          $endgroup$
                                                                          – MilkyWay90
                                                                          yesterday












                                                                          $begingroup$
                                                                          You can just define the T as a link and make it input a string, removing the need for "" in your input.
                                                                          $endgroup$
                                                                          – MilkyWay90
                                                                          22 hours ago




                                                                          $begingroup$
                                                                          You can just define the T as a link and make it input a string, removing the need for "" in your input.
                                                                          $endgroup$
                                                                          – MilkyWay90
                                                                          22 hours ago











                                                                          3












                                                                          $begingroup$


                                                                          PHP, 13 bytes





                                                                          <?=$argn[-1];


                                                                          Try it online!



                                                                          Run with php -nF input is STDIN. Example:



                                                                          $ echo 29845812674|php -nF lost.php





                                                                          share|improve this answer









                                                                          $endgroup$


















                                                                            3












                                                                            $begingroup$


                                                                            PHP, 13 bytes





                                                                            <?=$argn[-1];


                                                                            Try it online!



                                                                            Run with php -nF input is STDIN. Example:



                                                                            $ echo 29845812674|php -nF lost.php





                                                                            share|improve this answer









                                                                            $endgroup$
















                                                                              3












                                                                              3








                                                                              3





                                                                              $begingroup$


                                                                              PHP, 13 bytes





                                                                              <?=$argn[-1];


                                                                              Try it online!



                                                                              Run with php -nF input is STDIN. Example:



                                                                              $ echo 29845812674|php -nF lost.php





                                                                              share|improve this answer









                                                                              $endgroup$




                                                                              PHP, 13 bytes





                                                                              <?=$argn[-1];


                                                                              Try it online!



                                                                              Run with php -nF input is STDIN. Example:



                                                                              $ echo 29845812674|php -nF lost.php






                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered yesterday









                                                                              gwaughgwaugh

                                                                              1,838515




                                                                              1,838515























                                                                                  2












                                                                                  $begingroup$


                                                                                  Python 3, 14 bytes





                                                                                  lambda x:x[-1]


                                                                                  Try it online!






                                                                                  share|improve this answer









                                                                                  $endgroup$


















                                                                                    2












                                                                                    $begingroup$


                                                                                    Python 3, 14 bytes





                                                                                    lambda x:x[-1]


                                                                                    Try it online!






                                                                                    share|improve this answer









                                                                                    $endgroup$
















                                                                                      2












                                                                                      2








                                                                                      2





                                                                                      $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 2 days ago









                                                                                      MilkyWay90MilkyWay90

                                                                                      543212




                                                                                      543212























                                                                                          2












                                                                                          $begingroup$

                                                                                          PowerShell, 11 bytes



                                                                                          "$args"[-1]


                                                                                          Try it online!






                                                                                          share|improve this answer









                                                                                          $endgroup$


















                                                                                            2












                                                                                            $begingroup$

                                                                                            PowerShell, 11 bytes



                                                                                            "$args"[-1]


                                                                                            Try it online!






                                                                                            share|improve this answer









                                                                                            $endgroup$
















                                                                                              2












                                                                                              2








                                                                                              2





                                                                                              $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 2 days ago









                                                                                              Gabriel MillsGabriel Mills

                                                                                              604213




                                                                                              604213























                                                                                                  2












                                                                                                  $begingroup$


                                                                                                  05AB1E, 1 byte



                                                                                                  ¤


                                                                                                  Try it online!



                                                                                                  θ or ` would also work.






                                                                                                  share|improve this answer









                                                                                                  $endgroup$


















                                                                                                    2












                                                                                                    $begingroup$


                                                                                                    05AB1E, 1 byte



                                                                                                    ¤


                                                                                                    Try it online!



                                                                                                    θ or ` would also work.






                                                                                                    share|improve this answer









                                                                                                    $endgroup$
















                                                                                                      2












                                                                                                      2








                                                                                                      2





                                                                                                      $begingroup$


                                                                                                      05AB1E, 1 byte



                                                                                                      ¤


                                                                                                      Try it online!



                                                                                                      θ or ` would also work.






                                                                                                      share|improve this answer









                                                                                                      $endgroup$




                                                                                                      05AB1E, 1 byte



                                                                                                      ¤


                                                                                                      Try it online!



                                                                                                      θ or ` would also work.







                                                                                                      share|improve this answer












                                                                                                      share|improve this answer



                                                                                                      share|improve this answer










                                                                                                      answered yesterday









                                                                                                      EmignaEmigna

                                                                                                      47k433142




                                                                                                      47k433142























                                                                                                          2












                                                                                                          $begingroup$

                                                                                                          Twig, 37 bytes



                                                                                                          This just uses a simple "extract 1 char from the end and print it" aproach.



                                                                                                          {%macro a(a)%}{{a[-1:1]}}{%endmacro%}


                                                                                                          It was really easy to do, and test, but was fun!





                                                                                                          To use it, you have to put it on a .twig file and import it:



                                                                                                          {% import 'a.twig' as a %}
                                                                                                          {{ a.a("string") }} {# should display "g" #}




                                                                                                          You can test it on https://twigfiddle.com/aa19wd (testcases included)






                                                                                                          share|improve this answer









                                                                                                          $endgroup$













                                                                                                          • $begingroup$
                                                                                                            Ok, that's the first time I see a Twig golf.
                                                                                                            $endgroup$
                                                                                                            – Ven
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            @Ven I've been doing it for quite a while. Here's an example: codegolf.stackexchange.com/a/174040 and here's another one: codegolf.stackexchange.com/a/166800 (I have a few more, but well)
                                                                                                            $endgroup$
                                                                                                            – Ismael Miguel
                                                                                                            yesterday
















                                                                                                          2












                                                                                                          $begingroup$

                                                                                                          Twig, 37 bytes



                                                                                                          This just uses a simple "extract 1 char from the end and print it" aproach.



                                                                                                          {%macro a(a)%}{{a[-1:1]}}{%endmacro%}


                                                                                                          It was really easy to do, and test, but was fun!





                                                                                                          To use it, you have to put it on a .twig file and import it:



                                                                                                          {% import 'a.twig' as a %}
                                                                                                          {{ a.a("string") }} {# should display "g" #}




                                                                                                          You can test it on https://twigfiddle.com/aa19wd (testcases included)






                                                                                                          share|improve this answer









                                                                                                          $endgroup$













                                                                                                          • $begingroup$
                                                                                                            Ok, that's the first time I see a Twig golf.
                                                                                                            $endgroup$
                                                                                                            – Ven
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            @Ven I've been doing it for quite a while. Here's an example: codegolf.stackexchange.com/a/174040 and here's another one: codegolf.stackexchange.com/a/166800 (I have a few more, but well)
                                                                                                            $endgroup$
                                                                                                            – Ismael Miguel
                                                                                                            yesterday














                                                                                                          2












                                                                                                          2








                                                                                                          2





                                                                                                          $begingroup$

                                                                                                          Twig, 37 bytes



                                                                                                          This just uses a simple "extract 1 char from the end and print it" aproach.



                                                                                                          {%macro a(a)%}{{a[-1:1]}}{%endmacro%}


                                                                                                          It was really easy to do, and test, but was fun!





                                                                                                          To use it, you have to put it on a .twig file and import it:



                                                                                                          {% import 'a.twig' as a %}
                                                                                                          {{ a.a("string") }} {# should display "g" #}




                                                                                                          You can test it on https://twigfiddle.com/aa19wd (testcases included)






                                                                                                          share|improve this answer









                                                                                                          $endgroup$



                                                                                                          Twig, 37 bytes



                                                                                                          This just uses a simple "extract 1 char from the end and print it" aproach.



                                                                                                          {%macro a(a)%}{{a[-1:1]}}{%endmacro%}


                                                                                                          It was really easy to do, and test, but was fun!





                                                                                                          To use it, you have to put it on a .twig file and import it:



                                                                                                          {% import 'a.twig' as a %}
                                                                                                          {{ a.a("string") }} {# should display "g" #}




                                                                                                          You can test it on https://twigfiddle.com/aa19wd (testcases included)







                                                                                                          share|improve this answer












                                                                                                          share|improve this answer



                                                                                                          share|improve this answer










                                                                                                          answered yesterday









                                                                                                          Ismael MiguelIsmael Miguel

                                                                                                          6,25211533




                                                                                                          6,25211533












                                                                                                          • $begingroup$
                                                                                                            Ok, that's the first time I see a Twig golf.
                                                                                                            $endgroup$
                                                                                                            – Ven
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            @Ven I've been doing it for quite a while. Here's an example: codegolf.stackexchange.com/a/174040 and here's another one: codegolf.stackexchange.com/a/166800 (I have a few more, but well)
                                                                                                            $endgroup$
                                                                                                            – Ismael Miguel
                                                                                                            yesterday


















                                                                                                          • $begingroup$
                                                                                                            Ok, that's the first time I see a Twig golf.
                                                                                                            $endgroup$
                                                                                                            – Ven
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            @Ven I've been doing it for quite a while. Here's an example: codegolf.stackexchange.com/a/174040 and here's another one: codegolf.stackexchange.com/a/166800 (I have a few more, but well)
                                                                                                            $endgroup$
                                                                                                            – Ismael Miguel
                                                                                                            yesterday
















                                                                                                          $begingroup$
                                                                                                          Ok, that's the first time I see a Twig golf.
                                                                                                          $endgroup$
                                                                                                          – Ven
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          Ok, that's the first time I see a Twig golf.
                                                                                                          $endgroup$
                                                                                                          – Ven
                                                                                                          yesterday












                                                                                                          $begingroup$
                                                                                                          @Ven I've been doing it for quite a while. Here's an example: codegolf.stackexchange.com/a/174040 and here's another one: codegolf.stackexchange.com/a/166800 (I have a few more, but well)
                                                                                                          $endgroup$
                                                                                                          – Ismael Miguel
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          @Ven I've been doing it for quite a while. Here's an example: codegolf.stackexchange.com/a/174040 and here's another one: codegolf.stackexchange.com/a/166800 (I have a few more, but well)
                                                                                                          $endgroup$
                                                                                                          – Ismael Miguel
                                                                                                          yesterday











                                                                                                          2












                                                                                                          $begingroup$

                                                                                                          Python 3, 11 18 34 Bytes



                                                                                                          import sys;print(sys.argv[-1][-1])


                                                                                                          Usage via running the program as a python script on the command line. Input is provided as the last argument to the program.



                                                                                                          Try it online!






                                                                                                          share|improve this answer










                                                                                                          New contributor




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






                                                                                                          $endgroup$













                                                                                                          • $begingroup$
                                                                                                            This does not print anything or return anything from a function - snippets are not allowed, only functions or full programs.
                                                                                                            $endgroup$
                                                                                                            – Stephen
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Ah I see, didn’t think about that when I though of the answer. Only thought about running it in the interpreter.
                                                                                                            $endgroup$
                                                                                                            – Mrwerdo
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            This won't handle a newline in the input
                                                                                                            $endgroup$
                                                                                                            – Jo King
                                                                                                            yesterday






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            14
                                                                                                            $endgroup$
                                                                                                            – ASCII-only
                                                                                                            yesterday






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            How about this?
                                                                                                            $endgroup$
                                                                                                            – Mrwerdo
                                                                                                            yesterday
















                                                                                                          2












                                                                                                          $begingroup$

                                                                                                          Python 3, 11 18 34 Bytes



                                                                                                          import sys;print(sys.argv[-1][-1])


                                                                                                          Usage via running the program as a python script on the command line. Input is provided as the last argument to the program.



                                                                                                          Try it online!






                                                                                                          share|improve this answer










                                                                                                          New contributor




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






                                                                                                          $endgroup$













                                                                                                          • $begingroup$
                                                                                                            This does not print anything or return anything from a function - snippets are not allowed, only functions or full programs.
                                                                                                            $endgroup$
                                                                                                            – Stephen
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Ah I see, didn’t think about that when I though of the answer. Only thought about running it in the interpreter.
                                                                                                            $endgroup$
                                                                                                            – Mrwerdo
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            This won't handle a newline in the input
                                                                                                            $endgroup$
                                                                                                            – Jo King
                                                                                                            yesterday






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            14
                                                                                                            $endgroup$
                                                                                                            – ASCII-only
                                                                                                            yesterday






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            How about this?
                                                                                                            $endgroup$
                                                                                                            – Mrwerdo
                                                                                                            yesterday














                                                                                                          2












                                                                                                          2








                                                                                                          2





                                                                                                          $begingroup$

                                                                                                          Python 3, 11 18 34 Bytes



                                                                                                          import sys;print(sys.argv[-1][-1])


                                                                                                          Usage via running the program as a python script on the command line. Input is provided as the last argument to the program.



                                                                                                          Try it online!






                                                                                                          share|improve this answer










                                                                                                          New contributor




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






                                                                                                          $endgroup$



                                                                                                          Python 3, 11 18 34 Bytes



                                                                                                          import sys;print(sys.argv[-1][-1])


                                                                                                          Usage via running the program as a python script on the command line. Input is provided as the last argument to the program.



                                                                                                          Try it online!







                                                                                                          share|improve this answer










                                                                                                          New contributor




                                                                                                          Mrwerdo 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 answer



                                                                                                          share|improve this answer








                                                                                                          edited yesterday





















                                                                                                          New contributor




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









                                                                                                          answered yesterday









                                                                                                          MrwerdoMrwerdo

                                                                                                          1293




                                                                                                          1293




                                                                                                          New contributor




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





                                                                                                          New contributor





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






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












                                                                                                          • $begingroup$
                                                                                                            This does not print anything or return anything from a function - snippets are not allowed, only functions or full programs.
                                                                                                            $endgroup$
                                                                                                            – Stephen
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Ah I see, didn’t think about that when I though of the answer. Only thought about running it in the interpreter.
                                                                                                            $endgroup$
                                                                                                            – Mrwerdo
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            This won't handle a newline in the input
                                                                                                            $endgroup$
                                                                                                            – Jo King
                                                                                                            yesterday






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            14
                                                                                                            $endgroup$
                                                                                                            – ASCII-only
                                                                                                            yesterday






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            How about this?
                                                                                                            $endgroup$
                                                                                                            – Mrwerdo
                                                                                                            yesterday


















                                                                                                          • $begingroup$
                                                                                                            This does not print anything or return anything from a function - snippets are not allowed, only functions or full programs.
                                                                                                            $endgroup$
                                                                                                            – Stephen
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Ah I see, didn’t think about that when I though of the answer. Only thought about running it in the interpreter.
                                                                                                            $endgroup$
                                                                                                            – Mrwerdo
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            This won't handle a newline in the input
                                                                                                            $endgroup$
                                                                                                            – Jo King
                                                                                                            yesterday






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            14
                                                                                                            $endgroup$
                                                                                                            – ASCII-only
                                                                                                            yesterday






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            How about this?
                                                                                                            $endgroup$
                                                                                                            – Mrwerdo
                                                                                                            yesterday
















                                                                                                          $begingroup$
                                                                                                          This does not print anything or return anything from a function - snippets are not allowed, only functions or full programs.
                                                                                                          $endgroup$
                                                                                                          – Stephen
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          This does not print anything or return anything from a function - snippets are not allowed, only functions or full programs.
                                                                                                          $endgroup$
                                                                                                          – Stephen
                                                                                                          yesterday












                                                                                                          $begingroup$
                                                                                                          Ah I see, didn’t think about that when I though of the answer. Only thought about running it in the interpreter.
                                                                                                          $endgroup$
                                                                                                          – Mrwerdo
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          Ah I see, didn’t think about that when I though of the answer. Only thought about running it in the interpreter.
                                                                                                          $endgroup$
                                                                                                          – Mrwerdo
                                                                                                          yesterday












                                                                                                          $begingroup$
                                                                                                          This won't handle a newline in the input
                                                                                                          $endgroup$
                                                                                                          – Jo King
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          This won't handle a newline in the input
                                                                                                          $endgroup$
                                                                                                          – Jo King
                                                                                                          yesterday




                                                                                                          1




                                                                                                          1




                                                                                                          $begingroup$
                                                                                                          14
                                                                                                          $endgroup$
                                                                                                          – ASCII-only
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          14
                                                                                                          $endgroup$
                                                                                                          – ASCII-only
                                                                                                          yesterday




                                                                                                          1




                                                                                                          1




                                                                                                          $begingroup$
                                                                                                          How about this?
                                                                                                          $endgroup$
                                                                                                          – Mrwerdo
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          How about this?
                                                                                                          $endgroup$
                                                                                                          – Mrwerdo
                                                                                                          yesterday











                                                                                                          2












                                                                                                          $begingroup$


                                                                                                          C# 8.0, 8 bytes



                                                                                                          Requires .NET Core 3.0, which is in beta. This currently crashes the CLR due to a bug, but once the bug is fixed, this will run as expected and fulfill the challenge requirements.



                                                                                                          s=>s[^1]




                                                                                                          C# 8.0, Runs without crashing at time of writing, 22 bytes



                                                                                                          s=>s.ToCharArray()[^1]




                                                                                                          C# 8.0, Full Program, 78 bytes



                                                                                                          using C=System.Console;class A{static void Main(){C.Write(C.ReadLine()[^1]);}}






                                                                                                          share|improve this answer










                                                                                                          New contributor




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






                                                                                                          $endgroup$













                                                                                                          • $begingroup$
                                                                                                            The challenge mentions "output", so the last solution is probably the right one
                                                                                                            $endgroup$
                                                                                                            – Ven
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Dang, you outdid my console answer by a lot. How does the ^1 work?
                                                                                                            $endgroup$
                                                                                                            – Stackstuck
                                                                                                            yesterday












                                                                                                          • $begingroup$
                                                                                                            It's the new Index type. Starting an index with a caret indicates it's from the end, i.e. array[^n] is the same as array[array.Length - n]
                                                                                                            $endgroup$
                                                                                                            – briman0094
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Interesting! I always try to stay up to date with new C# features. Do you have any link / reference on that?
                                                                                                            $endgroup$
                                                                                                            – mortb
                                                                                                            12 hours ago






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            Found it: docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0
                                                                                                            $endgroup$
                                                                                                            – mortb
                                                                                                            12 hours ago
















                                                                                                          2












                                                                                                          $begingroup$


                                                                                                          C# 8.0, 8 bytes



                                                                                                          Requires .NET Core 3.0, which is in beta. This currently crashes the CLR due to a bug, but once the bug is fixed, this will run as expected and fulfill the challenge requirements.



                                                                                                          s=>s[^1]




                                                                                                          C# 8.0, Runs without crashing at time of writing, 22 bytes



                                                                                                          s=>s.ToCharArray()[^1]




                                                                                                          C# 8.0, Full Program, 78 bytes



                                                                                                          using C=System.Console;class A{static void Main(){C.Write(C.ReadLine()[^1]);}}






                                                                                                          share|improve this answer










                                                                                                          New contributor




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






                                                                                                          $endgroup$













                                                                                                          • $begingroup$
                                                                                                            The challenge mentions "output", so the last solution is probably the right one
                                                                                                            $endgroup$
                                                                                                            – Ven
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Dang, you outdid my console answer by a lot. How does the ^1 work?
                                                                                                            $endgroup$
                                                                                                            – Stackstuck
                                                                                                            yesterday












                                                                                                          • $begingroup$
                                                                                                            It's the new Index type. Starting an index with a caret indicates it's from the end, i.e. array[^n] is the same as array[array.Length - n]
                                                                                                            $endgroup$
                                                                                                            – briman0094
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Interesting! I always try to stay up to date with new C# features. Do you have any link / reference on that?
                                                                                                            $endgroup$
                                                                                                            – mortb
                                                                                                            12 hours ago






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            Found it: docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0
                                                                                                            $endgroup$
                                                                                                            – mortb
                                                                                                            12 hours ago














                                                                                                          2












                                                                                                          2








                                                                                                          2





                                                                                                          $begingroup$


                                                                                                          C# 8.0, 8 bytes



                                                                                                          Requires .NET Core 3.0, which is in beta. This currently crashes the CLR due to a bug, but once the bug is fixed, this will run as expected and fulfill the challenge requirements.



                                                                                                          s=>s[^1]




                                                                                                          C# 8.0, Runs without crashing at time of writing, 22 bytes



                                                                                                          s=>s.ToCharArray()[^1]




                                                                                                          C# 8.0, Full Program, 78 bytes



                                                                                                          using C=System.Console;class A{static void Main(){C.Write(C.ReadLine()[^1]);}}






                                                                                                          share|improve this answer










                                                                                                          New contributor




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






                                                                                                          $endgroup$




                                                                                                          C# 8.0, 8 bytes



                                                                                                          Requires .NET Core 3.0, which is in beta. This currently crashes the CLR due to a bug, but once the bug is fixed, this will run as expected and fulfill the challenge requirements.



                                                                                                          s=>s[^1]




                                                                                                          C# 8.0, Runs without crashing at time of writing, 22 bytes



                                                                                                          s=>s.ToCharArray()[^1]




                                                                                                          C# 8.0, Full Program, 78 bytes



                                                                                                          using C=System.Console;class A{static void Main(){C.Write(C.ReadLine()[^1]);}}







                                                                                                          share|improve this answer










                                                                                                          New contributor




                                                                                                          briman0094 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 answer



                                                                                                          share|improve this answer








                                                                                                          edited yesterday





















                                                                                                          New contributor




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









                                                                                                          answered yesterday









                                                                                                          briman0094briman0094

                                                                                                          1212




                                                                                                          1212




                                                                                                          New contributor




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





                                                                                                          New contributor





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






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












                                                                                                          • $begingroup$
                                                                                                            The challenge mentions "output", so the last solution is probably the right one
                                                                                                            $endgroup$
                                                                                                            – Ven
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Dang, you outdid my console answer by a lot. How does the ^1 work?
                                                                                                            $endgroup$
                                                                                                            – Stackstuck
                                                                                                            yesterday












                                                                                                          • $begingroup$
                                                                                                            It's the new Index type. Starting an index with a caret indicates it's from the end, i.e. array[^n] is the same as array[array.Length - n]
                                                                                                            $endgroup$
                                                                                                            – briman0094
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Interesting! I always try to stay up to date with new C# features. Do you have any link / reference on that?
                                                                                                            $endgroup$
                                                                                                            – mortb
                                                                                                            12 hours ago






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            Found it: docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0
                                                                                                            $endgroup$
                                                                                                            – mortb
                                                                                                            12 hours ago


















                                                                                                          • $begingroup$
                                                                                                            The challenge mentions "output", so the last solution is probably the right one
                                                                                                            $endgroup$
                                                                                                            – Ven
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Dang, you outdid my console answer by a lot. How does the ^1 work?
                                                                                                            $endgroup$
                                                                                                            – Stackstuck
                                                                                                            yesterday












                                                                                                          • $begingroup$
                                                                                                            It's the new Index type. Starting an index with a caret indicates it's from the end, i.e. array[^n] is the same as array[array.Length - n]
                                                                                                            $endgroup$
                                                                                                            – briman0094
                                                                                                            yesterday










                                                                                                          • $begingroup$
                                                                                                            Interesting! I always try to stay up to date with new C# features. Do you have any link / reference on that?
                                                                                                            $endgroup$
                                                                                                            – mortb
                                                                                                            12 hours ago






                                                                                                          • 1




                                                                                                            $begingroup$
                                                                                                            Found it: docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0
                                                                                                            $endgroup$
                                                                                                            – mortb
                                                                                                            12 hours ago
















                                                                                                          $begingroup$
                                                                                                          The challenge mentions "output", so the last solution is probably the right one
                                                                                                          $endgroup$
                                                                                                          – Ven
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          The challenge mentions "output", so the last solution is probably the right one
                                                                                                          $endgroup$
                                                                                                          – Ven
                                                                                                          yesterday












                                                                                                          $begingroup$
                                                                                                          Dang, you outdid my console answer by a lot. How does the ^1 work?
                                                                                                          $endgroup$
                                                                                                          – Stackstuck
                                                                                                          yesterday






                                                                                                          $begingroup$
                                                                                                          Dang, you outdid my console answer by a lot. How does the ^1 work?
                                                                                                          $endgroup$
                                                                                                          – Stackstuck
                                                                                                          yesterday














                                                                                                          $begingroup$
                                                                                                          It's the new Index type. Starting an index with a caret indicates it's from the end, i.e. array[^n] is the same as array[array.Length - n]
                                                                                                          $endgroup$
                                                                                                          – briman0094
                                                                                                          yesterday




                                                                                                          $begingroup$
                                                                                                          It's the new Index type. Starting an index with a caret indicates it's from the end, i.e. array[^n] is the same as array[array.Length - n]
                                                                                                          $endgroup$
                                                                                                          – briman0094
                                                                                                          yesterday












                                                                                                          $begingroup$
                                                                                                          Interesting! I always try to stay up to date with new C# features. Do you have any link / reference on that?
                                                                                                          $endgroup$
                                                                                                          – mortb
                                                                                                          12 hours ago




                                                                                                          $begingroup$
                                                                                                          Interesting! I always try to stay up to date with new C# features. Do you have any link / reference on that?
                                                                                                          $endgroup$
                                                                                                          – mortb
                                                                                                          12 hours ago




                                                                                                          1




                                                                                                          1




                                                                                                          $begingroup$
                                                                                                          Found it: docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0
                                                                                                          $endgroup$
                                                                                                          – mortb
                                                                                                          12 hours ago




                                                                                                          $begingroup$
                                                                                                          Found it: docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0
                                                                                                          $endgroup$
                                                                                                          – mortb
                                                                                                          12 hours ago











                                                                                                          1












                                                                                                          $begingroup$


                                                                                                          Wolfram Language (Mathematica), 16 bytes



                                                                                                          #~StringTake~-1&


                                                                                                          Try it online!






                                                                                                          share|improve this answer









                                                                                                          $endgroup$


















                                                                                                            1












                                                                                                            $begingroup$


                                                                                                            Wolfram Language (Mathematica), 16 bytes



                                                                                                            #~StringTake~-1&


                                                                                                            Try it online!






                                                                                                            share|improve this answer









                                                                                                            $endgroup$
















                                                                                                              1












                                                                                                              1








                                                                                                              1





                                                                                                              $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 2 days ago









                                                                                                              shrapshrap

                                                                                                              1113




                                                                                                              1113























                                                                                                                  1












                                                                                                                  $begingroup$


                                                                                                                  Turing Machine But Way Worse, 391 bytes



                                                                                                                  1 0 1 1 0 0 0
                                                                                                                  0 0 0 1 1 0 0
                                                                                                                  1 1 1 1 0 0 0
                                                                                                                  0 1 0 1 2 0 0
                                                                                                                  1 2 1 1 0 0 0
                                                                                                                  0 2 0 1 3 0 0
                                                                                                                  1 3 1 1 0 0 0
                                                                                                                  0 3 0 1 4 0 0
                                                                                                                  1 4 1 1 0 0 0
                                                                                                                  0 4 0 1 5 0 0
                                                                                                                  1 5 1 1 0 0 0
                                                                                                                  0 5 0 1 6 0 0
                                                                                                                  1 6 1 1 0 0 0
                                                                                                                  0 6 0 1 7 0 0
                                                                                                                  1 7 1 1 0 0 0
                                                                                                                  0 7 0 1 8 0 0
                                                                                                                  1 8 1 1 0 0 0
                                                                                                                  0 8 0 0 9 0 0
                                                                                                                  0 9 0 0 a 0 0
                                                                                                                  0 a 0 0 b 0 0
                                                                                                                  0 b 0 0 c 0 0
                                                                                                                  0 c 0 0 d 0 0
                                                                                                                  0 d 0 0 e 0 0
                                                                                                                  0 e 0 0 f 0 0
                                                                                                                  0 f 0 0 h 0 0
                                                                                                                  0 h 0 0 g 0 0
                                                                                                                  0 g 0 0 0 1 1
                                                                                                                  1 g 1 0 0 1 1


                                                                                                                  Try it online!



                                                                                                                  EXPLANATION



                                                                                                                  Detect eight zero bits (which will occur at the end of the input, since TMBWW uses an infinite tape of bits.)
                                                                                                                  1 1 1 1 0 0 0
                                                                                                                  0 1 0 1 2 0 0
                                                                                                                  1 2 1 1 0 0 0
                                                                                                                  0 2 0 1 3 0 0
                                                                                                                  1 3 1 1 0 0 0
                                                                                                                  0 3 0 1 4 0 0
                                                                                                                  1 4 1 1 0 0 0
                                                                                                                  0 4 0 1 5 0 0
                                                                                                                  1 5 1 1 0 0 0
                                                                                                                  0 5 0 1 6 0 0
                                                                                                                  1 6 1 1 0 0 0
                                                                                                                  0 6 0 1 7 0 0
                                                                                                                  1 7 1 1 0 0 0
                                                                                                                  0 7 0 1 8 0 0
                                                                                                                  1 8 1 1 0 0 0
                                                                                                                  0 8 0 0 9 0 0

                                                                                                                  -------------

                                                                                                                  When eight 0 bits are detected, move back to the final byte of the input and print it out while halting the program.
                                                                                                                  0 9 0 0 a 0 0
                                                                                                                  0 a 0 0 b 0 0
                                                                                                                  0 b 0 0 c 0 0
                                                                                                                  0 c 0 0 d 0 0
                                                                                                                  0 d 0 0 e 0 0
                                                                                                                  0 e 0 0 f 0 0
                                                                                                                  0 f 0 0 h 0 0
                                                                                                                  0 h 0 0 g 0 0
                                                                                                                  0 g 0 0 0 1 1
                                                                                                                  1 g 1 0 0 1 1





                                                                                                                  share|improve this answer









                                                                                                                  $endgroup$


















                                                                                                                    1












                                                                                                                    $begingroup$


                                                                                                                    Turing Machine But Way Worse, 391 bytes



                                                                                                                    1 0 1 1 0 0 0
                                                                                                                    0 0 0 1 1 0 0
                                                                                                                    1 1 1 1 0 0 0
                                                                                                                    0 1 0 1 2 0 0
                                                                                                                    1 2 1 1 0 0 0
                                                                                                                    0 2 0 1 3 0 0
                                                                                                                    1 3 1 1 0 0 0
                                                                                                                    0 3 0 1 4 0 0
                                                                                                                    1 4 1 1 0 0 0
                                                                                                                    0 4 0 1 5 0 0
                                                                                                                    1 5 1 1 0 0 0
                                                                                                                    0 5 0 1 6 0 0
                                                                                                                    1 6 1 1 0 0 0
                                                                                                                    0 6 0 1 7 0 0
                                                                                                                    1 7 1 1 0 0 0
                                                                                                                    0 7 0 1 8 0 0
                                                                                                                    1 8 1 1 0 0 0
                                                                                                                    0 8 0 0 9 0 0
                                                                                                                    0 9 0 0 a 0 0
                                                                                                                    0 a 0 0 b 0 0
                                                                                                                    0 b 0 0 c 0 0
                                                                                                                    0 c 0 0 d 0 0
                                                                                                                    0 d 0 0 e 0 0
                                                                                                                    0 e 0 0 f 0 0
                                                                                                                    0 f 0 0 h 0 0
                                                                                                                    0 h 0 0 g 0 0
                                                                                                                    0 g 0 0 0 1 1
                                                                                                                    1 g 1 0 0 1 1


                                                                                                                    Try it online!



                                                                                                                    EXPLANATION



                                                                                                                    Detect eight zero bits (which will occur at the end of the input, since TMBWW uses an infinite tape of bits.)
                                                                                                                    1 1 1 1 0 0 0
                                                                                                                    0 1 0 1 2 0 0
                                                                                                                    1 2 1 1 0 0 0
                                                                                                                    0 2 0 1 3 0 0
                                                                                                                    1 3 1 1 0 0 0
                                                                                                                    0 3 0 1 4 0 0
                                                                                                                    1 4 1 1 0 0 0
                                                                                                                    0 4 0 1 5 0 0
                                                                                                                    1 5 1 1 0 0 0
                                                                                                                    0 5 0 1 6 0 0
                                                                                                                    1 6 1 1 0 0 0
                                                                                                                    0 6 0 1 7 0 0
                                                                                                                    1 7 1 1 0 0 0
                                                                                                                    0 7 0 1 8 0 0
                                                                                                                    1 8 1 1 0 0 0
                                                                                                                    0 8 0 0 9 0 0

                                                                                                                    -------------

                                                                                                                    When eight 0 bits are detected, move back to the final byte of the input and print it out while halting the program.
                                                                                                                    0 9 0 0 a 0 0
                                                                                                                    0 a 0 0 b 0 0
                                                                                                                    0 b 0 0 c 0 0
                                                                                                                    0 c 0 0 d 0 0
                                                                                                                    0 d 0 0 e 0 0
                                                                                                                    0 e 0 0 f 0 0
                                                                                                                    0 f 0 0 h 0 0
                                                                                                                    0 h 0 0 g 0 0
                                                                                                                    0 g 0 0 0 1 1
                                                                                                                    1 g 1 0 0 1 1





                                                                                                                    share|improve this answer









                                                                                                                    $endgroup$
















                                                                                                                      1












                                                                                                                      1








                                                                                                                      1





                                                                                                                      $begingroup$


                                                                                                                      Turing Machine But Way Worse, 391 bytes



                                                                                                                      1 0 1 1 0 0 0
                                                                                                                      0 0 0 1 1 0 0
                                                                                                                      1 1 1 1 0 0 0
                                                                                                                      0 1 0 1 2 0 0
                                                                                                                      1 2 1 1 0 0 0
                                                                                                                      0 2 0 1 3 0 0
                                                                                                                      1 3 1 1 0 0 0
                                                                                                                      0 3 0 1 4 0 0
                                                                                                                      1 4 1 1 0 0 0
                                                                                                                      0 4 0 1 5 0 0
                                                                                                                      1 5 1 1 0 0 0
                                                                                                                      0 5 0 1 6 0 0
                                                                                                                      1 6 1 1 0 0 0
                                                                                                                      0 6 0 1 7 0 0
                                                                                                                      1 7 1 1 0 0 0
                                                                                                                      0 7 0 1 8 0 0
                                                                                                                      1 8 1 1 0 0 0
                                                                                                                      0 8 0 0 9 0 0
                                                                                                                      0 9 0 0 a 0 0
                                                                                                                      0 a 0 0 b 0 0
                                                                                                                      0 b 0 0 c 0 0
                                                                                                                      0 c 0 0 d 0 0
                                                                                                                      0 d 0 0 e 0 0
                                                                                                                      0 e 0 0 f 0 0
                                                                                                                      0 f 0 0 h 0 0
                                                                                                                      0 h 0 0 g 0 0
                                                                                                                      0 g 0 0 0 1 1
                                                                                                                      1 g 1 0 0 1 1


                                                                                                                      Try it online!



                                                                                                                      EXPLANATION



                                                                                                                      Detect eight zero bits (which will occur at the end of the input, since TMBWW uses an infinite tape of bits.)
                                                                                                                      1 1 1 1 0 0 0
                                                                                                                      0 1 0 1 2 0 0
                                                                                                                      1 2 1 1 0 0 0
                                                                                                                      0 2 0 1 3 0 0
                                                                                                                      1 3 1 1 0 0 0
                                                                                                                      0 3 0 1 4 0 0
                                                                                                                      1 4 1 1 0 0 0
                                                                                                                      0 4 0 1 5 0 0
                                                                                                                      1 5 1 1 0 0 0
                                                                                                                      0 5 0 1 6 0 0
                                                                                                                      1 6 1 1 0 0 0
                                                                                                                      0 6 0 1 7 0 0
                                                                                                                      1 7 1 1 0 0 0
                                                                                                                      0 7 0 1 8 0 0
                                                                                                                      1 8 1 1 0 0 0
                                                                                                                      0 8 0 0 9 0 0

                                                                                                                      -------------

                                                                                                                      When eight 0 bits are detected, move back to the final byte of the input and print it out while halting the program.
                                                                                                                      0 9 0 0 a 0 0
                                                                                                                      0 a 0 0 b 0 0
                                                                                                                      0 b 0 0 c 0 0
                                                                                                                      0 c 0 0 d 0 0
                                                                                                                      0 d 0 0 e 0 0
                                                                                                                      0 e 0 0 f 0 0
                                                                                                                      0 f 0 0 h 0 0
                                                                                                                      0 h 0 0 g 0 0
                                                                                                                      0 g 0 0 0 1 1
                                                                                                                      1 g 1 0 0 1 1





                                                                                                                      share|improve this answer









                                                                                                                      $endgroup$




                                                                                                                      Turing Machine But Way Worse, 391 bytes



                                                                                                                      1 0 1 1 0 0 0
                                                                                                                      0 0 0 1 1 0 0
                                                                                                                      1 1 1 1 0 0 0
                                                                                                                      0 1 0 1 2 0 0
                                                                                                                      1 2 1 1 0 0 0
                                                                                                                      0 2 0 1 3 0 0
                                                                                                                      1 3 1 1 0 0 0
                                                                                                                      0 3 0 1 4 0 0
                                                                                                                      1 4 1 1 0 0 0
                                                                                                                      0 4 0 1 5 0 0
                                                                                                                      1 5 1 1 0 0 0
                                                                                                                      0 5 0 1 6 0 0
                                                                                                                      1 6 1 1 0 0 0
                                                                                                                      0 6 0 1 7 0 0
                                                                                                                      1 7 1 1 0 0 0
                                                                                                                      0 7 0 1 8 0 0
                                                                                                                      1 8 1 1 0 0 0
                                                                                                                      0 8 0 0 9 0 0
                                                                                                                      0 9 0 0 a 0 0
                                                                                                                      0 a 0 0 b 0 0
                                                                                                                      0 b 0 0 c 0 0
                                                                                                                      0 c 0 0 d 0 0
                                                                                                                      0 d 0 0 e 0 0
                                                                                                                      0 e 0 0 f 0 0
                                                                                                                      0 f 0 0 h 0 0
                                                                                                                      0 h 0 0 g 0 0
                                                                                                                      0 g 0 0 0 1 1
                                                                                                                      1 g 1 0 0 1 1


                                                                                                                      Try it online!



                                                                                                                      EXPLANATION



                                                                                                                      Detect eight zero bits (which will occur at the end of the input, since TMBWW uses an infinite tape of bits.)
                                                                                                                      1 1 1 1 0 0 0
                                                                                                                      0 1 0 1 2 0 0
                                                                                                                      1 2 1 1 0 0 0
                                                                                                                      0 2 0 1 3 0 0
                                                                                                                      1 3 1 1 0 0 0
                                                                                                                      0 3 0 1 4 0 0
                                                                                                                      1 4 1 1 0 0 0
                                                                                                                      0 4 0 1 5 0 0
                                                                                                                      1 5 1 1 0 0 0
                                                                                                                      0 5 0 1 6 0 0
                                                                                                                      1 6 1 1 0 0 0
                                                                                                                      0 6 0 1 7 0 0
                                                                                                                      1 7 1 1 0 0 0
                                                                                                                      0 7 0 1 8 0 0
                                                                                                                      1 8 1 1 0 0 0
                                                                                                                      0 8 0 0 9 0 0

                                                                                                                      -------------

                                                                                                                      When eight 0 bits are detected, move back to the final byte of the input and print it out while halting the program.
                                                                                                                      0 9 0 0 a 0 0
                                                                                                                      0 a 0 0 b 0 0
                                                                                                                      0 b 0 0 c 0 0
                                                                                                                      0 c 0 0 d 0 0
                                                                                                                      0 d 0 0 e 0 0
                                                                                                                      0 e 0 0 f 0 0
                                                                                                                      0 f 0 0 h 0 0
                                                                                                                      0 h 0 0 g 0 0
                                                                                                                      0 g 0 0 0 1 1
                                                                                                                      1 g 1 0 0 1 1






                                                                                                                      share|improve this answer












                                                                                                                      share|improve this answer



                                                                                                                      share|improve this answer










                                                                                                                      answered yesterday









                                                                                                                      MilkyWay90MilkyWay90

                                                                                                                      543212




                                                                                                                      543212























                                                                                                                          1












                                                                                                                          $begingroup$


                                                                                                                          Befunge-98, 5 bytes



                                                                                                                          ~2j@,


                                                                                                                          Try it online!



                                                                                                                          Explanation:



                                                                                                                          ~           Take input
                                                                                                                          2j Skip next two instructions
                                                                                                                          ~ Repeat until EOF, where it reflects
                                                                                                                          @, Print the last character and exit





                                                                                                                          share|improve this answer









                                                                                                                          $endgroup$


















                                                                                                                            1












                                                                                                                            $begingroup$


                                                                                                                            Befunge-98, 5 bytes



                                                                                                                            ~2j@,


                                                                                                                            Try it online!



                                                                                                                            Explanation:



                                                                                                                            ~           Take input
                                                                                                                            2j Skip next two instructions
                                                                                                                            ~ Repeat until EOF, where it reflects
                                                                                                                            @, Print the last character and exit





                                                                                                                            share|improve this answer









                                                                                                                            $endgroup$
















                                                                                                                              1












                                                                                                                              1








                                                                                                                              1





                                                                                                                              $begingroup$


                                                                                                                              Befunge-98, 5 bytes



                                                                                                                              ~2j@,


                                                                                                                              Try it online!



                                                                                                                              Explanation:



                                                                                                                              ~           Take input
                                                                                                                              2j Skip next two instructions
                                                                                                                              ~ Repeat until EOF, where it reflects
                                                                                                                              @, Print the last character and exit





                                                                                                                              share|improve this answer









                                                                                                                              $endgroup$




                                                                                                                              Befunge-98, 5 bytes



                                                                                                                              ~2j@,


                                                                                                                              Try it online!



                                                                                                                              Explanation:



                                                                                                                              ~           Take input
                                                                                                                              2j Skip next two instructions
                                                                                                                              ~ Repeat until EOF, where it reflects
                                                                                                                              @, Print the last character and exit






                                                                                                                              share|improve this answer












                                                                                                                              share|improve this answer



                                                                                                                              share|improve this answer










                                                                                                                              answered yesterday









                                                                                                                              Jo KingJo King

                                                                                                                              25k359128




                                                                                                                              25k359128























                                                                                                                                  1












                                                                                                                                  $begingroup$


                                                                                                                                  C# (Visual C# Interactive Compiler), 11 bytes





                                                                                                                                  x=>x.Last()


                                                                                                                                  Try it online!






                                                                                                                                  share|improve this answer











                                                                                                                                  $endgroup$













                                                                                                                                  • $begingroup$
                                                                                                                                    you can use a function :P
                                                                                                                                    $endgroup$
                                                                                                                                    – ASCII-only
                                                                                                                                    yesterday










                                                                                                                                  • $begingroup$
                                                                                                                                    OK - Ill update my answer :)
                                                                                                                                    $endgroup$
                                                                                                                                    – dana
                                                                                                                                    yesterday






                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    uhm why is testcase in STDIN not footer
                                                                                                                                    $endgroup$
                                                                                                                                    – ASCII-only
                                                                                                                                    yesterday










                                                                                                                                  • $begingroup$
                                                                                                                                    Wow - It's been a while. Thanks for pointing that out ;)
                                                                                                                                    $endgroup$
                                                                                                                                    – dana
                                                                                                                                    yesterday






                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    That's not how I understand it. I understand that it should print the last non-empty character. We need to ask OP.
                                                                                                                                    $endgroup$
                                                                                                                                    – Ven
                                                                                                                                    yesterday
















                                                                                                                                  1












                                                                                                                                  $begingroup$


                                                                                                                                  C# (Visual C# Interactive Compiler), 11 bytes





                                                                                                                                  x=>x.Last()


                                                                                                                                  Try it online!






                                                                                                                                  share|improve this answer











                                                                                                                                  $endgroup$













                                                                                                                                  • $begingroup$
                                                                                                                                    you can use a function :P
                                                                                                                                    $endgroup$
                                                                                                                                    – ASCII-only
                                                                                                                                    yesterday










                                                                                                                                  • $begingroup$
                                                                                                                                    OK - Ill update my answer :)
                                                                                                                                    $endgroup$
                                                                                                                                    – dana
                                                                                                                                    yesterday






                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    uhm why is testcase in STDIN not footer
                                                                                                                                    $endgroup$
                                                                                                                                    – ASCII-only
                                                                                                                                    yesterday










                                                                                                                                  • $begingroup$
                                                                                                                                    Wow - It's been a while. Thanks for pointing that out ;)
                                                                                                                                    $endgroup$
                                                                                                                                    – dana
                                                                                                                                    yesterday






                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    That's not how I understand it. I understand that it should print the last non-empty character. We need to ask OP.
                                                                                                                                    $endgroup$
                                                                                                                                    – Ven
                                                                                                                                    yesterday














                                                                                                                                  1












                                                                                                                                  1








                                                                                                                                  1





                                                                                                                                  $begingroup$


                                                                                                                                  C# (Visual C# Interactive Compiler), 11 bytes





                                                                                                                                  x=>x.Last()


                                                                                                                                  Try it online!






                                                                                                                                  share|improve this answer











                                                                                                                                  $endgroup$




                                                                                                                                  C# (Visual C# Interactive Compiler), 11 bytes





                                                                                                                                  x=>x.Last()


                                                                                                                                  Try it online!







                                                                                                                                  share|improve this answer














                                                                                                                                  share|improve this answer



                                                                                                                                  share|improve this answer








                                                                                                                                  edited yesterday

























                                                                                                                                  answered yesterday









                                                                                                                                  danadana

                                                                                                                                  1,511167




                                                                                                                                  1,511167












                                                                                                                                  • $begingroup$
                                                                                                                                    you can use a function :P
                                                                                                                                    $endgroup$
                                                                                                                                    – ASCII-only
                                                                                                                                    yesterday










                                                                                                                                  • $begingroup$
                                                                                                                                    OK - Ill update my answer :)
                                                                                                                                    $endgroup$
                                                                                                                                    – dana
                                                                                                                                    yesterday






                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    uhm why is testcase in STDIN not footer
                                                                                                                                    $endgroup$
                                                                                                                                    – ASCII-only
                                                                                                                                    yesterday










                                                                                                                                  • $begingroup$
                                                                                                                                    Wow - It's been a while. Thanks for pointing that out ;)
                                                                                                                                    $endgroup$
                                                                                                                                    – dana
                                                                                                                                    yesterday






                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    That's not how I understand it. I understand that it should print the last non-empty character. We need to ask OP.
                                                                                                                                    $endgroup$
                                                                                                                                    – Ven
                                                                                                                                    yesterday


















                                                                                                                                  • $begingroup$
                                                                                                                                    you can use a function :P
                                                                                                                                    $endgroup$
                                                                                                                                    – ASCII-only
                                                                                                                                    yesterday










                                                                                                                                  • $begingroup$
                                                                                                                                    OK - Ill update my answer :)
                                                                                                                                    $endgroup$
                                                                                                                                    – dana
                                                                                                                                    yesterday






                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    uhm why is testcase in STDIN not footer
                                                                                                                                    $endgroup$
                                                                                                                                    – ASCII-only
                                                                                                                                    yesterday










                                                                                                                                  • $begingroup$
                                                                                                                                    Wow - It's been a while. Thanks for pointing that out ;)
                                                                                                                                    $endgroup$
                                                                                                                                    – dana
                                                                                                                                    yesterday






                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    That's not how I understand it. I understand that it should print the last non-empty character. We need to ask OP.
                                                                                                                                    $endgroup$
                                                                                                                                    – Ven
                                                                                                                                    yesterday
















                                                                                                                                  $begingroup$
                                                                                                                                  you can use a function :P
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  yesterday




                                                                                                                                  $begingroup$
                                                                                                                                  you can use a function :P
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  yesterday












                                                                                                                                  $begingroup$
                                                                                                                                  OK - Ill update my answer :)
                                                                                                                                  $endgroup$
                                                                                                                                  – dana
                                                                                                                                  yesterday




                                                                                                                                  $begingroup$
                                                                                                                                  OK - Ill update my answer :)
                                                                                                                                  $endgroup$
                                                                                                                                  – dana
                                                                                                                                  yesterday




                                                                                                                                  1




                                                                                                                                  1




                                                                                                                                  $begingroup$
                                                                                                                                  uhm why is testcase in STDIN not footer
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  yesterday




                                                                                                                                  $begingroup$
                                                                                                                                  uhm why is testcase in STDIN not footer
                                                                                                                                  $endgroup$
                                                                                                                                  – ASCII-only
                                                                                                                                  yesterday












                                                                                                                                  $begingroup$
                                                                                                                                  Wow - It's been a while. Thanks for pointing that out ;)
                                                                                                                                  $endgroup$
                                                                                                                                  – dana
                                                                                                                                  yesterday




                                                                                                                                  $begingroup$
                                                                                                                                  Wow - It's been a while. Thanks for pointing that out ;)
                                                                                                                                  $endgroup$
                                                                                                                                  – dana
                                                                                                                                  yesterday




                                                                                                                                  1




                                                                                                                                  1




                                                                                                                                  $begingroup$
                                                                                                                                  That's not how I understand it. I understand that it should print the last non-empty character. We need to ask OP.
                                                                                                                                  $endgroup$
                                                                                                                                  – Ven
                                                                                                                                  yesterday




                                                                                                                                  $begingroup$
                                                                                                                                  That's not how I understand it. I understand that it should print the last non-empty character. We need to ask OP.
                                                                                                                                  $endgroup$
                                                                                                                                  – Ven
                                                                                                                                  yesterday











                                                                                                                                  1












                                                                                                                                  $begingroup$


                                                                                                                                  Japt, 1 byte



                                                                                                                                  Ì


                                                                                                                                  Try it online!



                                                                                                                                  -1 byte thanks to Quintec!






                                                                                                                                  share|improve this answer











                                                                                                                                  $endgroup$









                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    1 byte
                                                                                                                                    $endgroup$
                                                                                                                                    – Quintec
                                                                                                                                    yesterday
















                                                                                                                                  1












                                                                                                                                  $begingroup$


                                                                                                                                  Japt, 1 byte



                                                                                                                                  Ì


                                                                                                                                  Try it online!



                                                                                                                                  -1 byte thanks to Quintec!






                                                                                                                                  share|improve this answer











                                                                                                                                  $endgroup$









                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    1 byte
                                                                                                                                    $endgroup$
                                                                                                                                    – Quintec
                                                                                                                                    yesterday














                                                                                                                                  1












                                                                                                                                  1








                                                                                                                                  1





                                                                                                                                  $begingroup$


                                                                                                                                  Japt, 1 byte



                                                                                                                                  Ì


                                                                                                                                  Try it online!



                                                                                                                                  -1 byte thanks to Quintec!






                                                                                                                                  share|improve this answer











                                                                                                                                  $endgroup$




                                                                                                                                  Japt, 1 byte



                                                                                                                                  Ì


                                                                                                                                  Try it online!



                                                                                                                                  -1 byte thanks to Quintec!







                                                                                                                                  share|improve this answer














                                                                                                                                  share|improve this answer



                                                                                                                                  share|improve this answer








                                                                                                                                  edited yesterday

























                                                                                                                                  answered yesterday









                                                                                                                                  danadana

                                                                                                                                  1,511167




                                                                                                                                  1,511167








                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    1 byte
                                                                                                                                    $endgroup$
                                                                                                                                    – Quintec
                                                                                                                                    yesterday














                                                                                                                                  • 1




                                                                                                                                    $begingroup$
                                                                                                                                    1 byte
                                                                                                                                    $endgroup$
                                                                                                                                    – Quintec
                                                                                                                                    yesterday








                                                                                                                                  1




                                                                                                                                  1




                                                                                                                                  $begingroup$
                                                                                                                                  1 byte
                                                                                                                                  $endgroup$
                                                                                                                                  – Quintec
                                                                                                                                  yesterday




                                                                                                                                  $begingroup$
                                                                                                                                  1 byte
                                                                                                                                  $endgroup$
                                                                                                                                  – Quintec
                                                                                                                                  yesterday











                                                                                                                                  1












                                                                                                                                  $begingroup$

                                                                                                                                  APL+WIN, 4 bytes



                                                                                                                                  ¯1↑⎕


                                                                                                                                  Prompt for input string and select last byte.






                                                                                                                                  share|improve this answer









                                                                                                                                  $endgroup$


















                                                                                                                                    1












                                                                                                                                    $begingroup$

                                                                                                                                    APL+WIN, 4 bytes



                                                                                                                                    ¯1↑⎕


                                                                                                                                    Prompt for input string and select last byte.






                                                                                                                                    share|improve this answer









                                                                                                                                    $endgroup$
















                                                                                                                                      1












                                                                                                                                      1








                                                                                                                                      1





                                                                                                                                      $begingroup$

                                                                                                                                      APL+WIN, 4 bytes



                                                                                                                                      ¯1↑⎕


                                                                                                                                      Prompt for input string and select last byte.






                                                                                                                                      share|improve this answer









                                                                                                                                      $endgroup$



                                                                                                                                      APL+WIN, 4 bytes



                                                                                                                                      ¯1↑⎕


                                                                                                                                      Prompt for input string and select last byte.







                                                                                                                                      share|improve this answer












                                                                                                                                      share|improve this answer



                                                                                                                                      share|improve this answer










                                                                                                                                      answered yesterday









                                                                                                                                      GrahamGraham

                                                                                                                                      2,55678




                                                                                                                                      2,55678























                                                                                                                                          1












                                                                                                                                          $begingroup$


                                                                                                                                          Whitespace, 54 bytes



                                                                                                                                          [N
                                                                                                                                          S S N
                                                                                                                                          _Create_Label_LOOP][S S S N
                                                                                                                                          _Push_0][S N
                                                                                                                                          S _Duplicate_0][T N
                                                                                                                                          T S _Read_STDIN_as_character][T T T _Retrieve_input][S N
                                                                                                                                          S _Duplicate][S S S T S T S N
                                                                                                                                          _Push_10][T S S T _Subtract][N
                                                                                                                                          T S S N
                                                                                                                                          _If_0_Jump_to_Label_PRINT][N
                                                                                                                                          S N
                                                                                                                                          N
                                                                                                                                          _Jump_to_Label_LOOP][N
                                                                                                                                          S S S N
                                                                                                                                          _Create_Label_PRINT][S N
                                                                                                                                          N
                                                                                                                                          _Discard_top][T N
                                                                                                                                          S S _Print_as_character]


                                                                                                                                          Letters S (space), T (tab), and N (new-line) added as highlighting only.
                                                                                                                                          [..._some_action] added as explanation only.



                                                                                                                                          Since Whitespace can only take input as integer or character, we must add a trailing character to indicate we're done with the input-string after reading it character by character, for which I've used a newline.



                                                                                                                                          Try it online (with raw spaces, tabs and new-lines only).



                                                                                                                                          Example run: input = A2#



                                                                                                                                          Command    Explanation                   Stack                Heap    STDIN STDOUT STDERR

                                                                                                                                          NSSN Create Label_LOOP
                                                                                                                                          SSSN Push 0 [0]
                                                                                                                                          SNS Duplicate top (0) [0,0]
                                                                                                                                          TNTS Read STDIN as character [0] {0:65} A
                                                                                                                                          TTT Retrieve at heap address (0) [65] {0:65}
                                                                                                                                          SNS Duplicate top (65) [65,65] {0:65}
                                                                                                                                          SSSTSTSN Push 10 [65,65,10] {0:65}
                                                                                                                                          TSST Subtract top two (65-10) [65,55] {0:65}
                                                                                                                                          NTSSN If 0: Jump to Label_PRINT [65] {0:65}
                                                                                                                                          NSNN Jump to Label_LOOP [65] {0:65}

                                                                                                                                          SSSN Push 0 [65,0]
                                                                                                                                          SNS Duplicate top (0) [65,0,0]
                                                                                                                                          TNTS Read STDIN as character [65,0] {0:50} 2
                                                                                                                                          TTT Retrieve at heap address (0) [65,50] {0:50}
                                                                                                                                          SNS Duplicate top (50) [65,50,50] {0:50}
                                                                                                                                          SSSTSTSN Push 10 [65,50,50,10] {0:50}
                                                                                                                                          TSST Subtract top two (50-10) [65,50,40] {0:50}
                                                                                                                                          NTSSN If 0: Jump to Label_PRINT [65,50] {0:50}
                                                                                                                                          NSNN Jump to Label_LOOP [65,50] {0:50}

                                                                                                                                          SSSN Push 0 [65,50,0]
                                                                                                                                          SNS Duplicate top (0) [65,50,0,0]
                                                                                                                                          TNTS Read STDIN as character [65,50,0] {0:35} #
                                                                                                                                          TTT Retrieve at heap address (0) [65,50,35] {0:35}
                                                                                                                                          SNS Duplicate top (35) [65,50,35,35] {0:35}
                                                                                                                                          SSSTSTSN Push 10 [65,50,35,35,10] {0:35}
                                                                                                                                          TSST Subtract top two (35-10) [65,50,35,25] {0:35}
                                                                                                                                          NTSSN If 0: Jump to Label_PRINT [65,50,35] {0:35}
                                                                                                                                          NSNN Jump to Label_LOOP [65,50,35] {0:35}

                                                                                                                                          SSSN Push 0 [65,50,35,0]
                                                                                                                                          SNS Duplicate top (0) [65,50,35,0,0]
                                                                                                                                          TNTS Read STDIN as character [65,50,35,0] {0:10} n
                                                                                                                                          TTT Retrieve at heap address (0) [65,50,35,10] {0:10}
                                                                                                                                          SNS Duplicate top (10) [65,50,35,10,10] {0:10}
                                                                                                                                          SSSTSTSN Push 10 [65,50,35,10,10,10] {0:10}
                                                                                                                                          TSST Subtract top two (10-10) [65,50,35,10,0] {0:10}
                                                                                                                                          NTSSN If 0: Jump to Label_PRINT [65,50,35,10] {0:10}

                                                                                                                                          NSSSN Create Label_PRINT [65,50,35,10] {0:10}
                                                                                                                                          SNN Discard top [65,50,35] {0:10}
                                                                                                                                          TNSS Print as character to STDOUT [65,50] {0:10} #
                                                                                                                                          {0:10} error


                                                                                                                                          Stops with the error: Exit not defined.






                                                                                                                                          share|improve this answer









                                                                                                                                          $endgroup$


















                                                                                                                                            1












                                                                                                                                            $begingroup$


                                                                                                                                            Whitespace, 54 bytes



                                                                                                                                            [N
                                                                                                                                            S S N
                                                                                                                                            _Create_Label_LOOP][S S S N
                                                                                                                                            _Push_0][S N
                                                                                                                                            S _Duplicate_0][T N
                                                                                                                                            T S _Read_STDIN_as_character][T T T _Retrieve_input][S N
                                                                                                                                            S _Duplicate][S S S T S T S N
                                                                                                                                            _Push_10][T S S T _Subtract][N
                                                                                                                                            T S S N
                                                                                                                                            _If_0_Jump_to_Label_PRINT][N
                                                                                                                                            S N
                                                                                                                                            N
                                                                                                                                            _Jump_to_Label_LOOP][N
                                                                                                                                            S S S N
                                                                                                                                            _Create_Label_PRINT][S N
                                                                                                                                            N
                                                                                                                                            _Discard_top][T N
                                                                                                                                            S S _Print_as_character]


                                                                                                                                            Letters S (space), T (tab), and N (new-line) added as highlighting only.
                                                                                                                                            [..._some_action] added as explanation only.



                                                                                                                                            Since Whitespace can only take input as integer or character, we must add a trailing character to indicate we're done with the input-string after reading it character by character, for which I've used a newline.



                                                                                                                                            Try it online (with raw spaces, tabs and new-lines only).



                                                                                                                                            Example run: input = A2#



                                                                                                                                            Command    Explanation                   Stack                Heap    STDIN STDOUT STDERR

                                                                                                                                            NSSN Create Label_LOOP
                                                                                                                                            SSSN Push 0 [0]
                                                                                                                                            SNS Duplicate top (0) [0,0]
                                                                                                                                            TNTS Read STDIN as character [0] {0:65} A
                                                                                                                                            TTT Retrieve at heap address (0) [65] {0:65}
                                                                                                                                            SNS Duplicate top (65) [65,65] {0:65}
                                                                                                                                            SSSTSTSN Push 10 [65,65,10] {0:65}
                                                                                                                                            TSST Subtract top two (65-10) [65,55] {0:65}
                                                                                                                                            NTSSN If 0: Jump to Label_PRINT [65] {0:65}
                                                                                                                                            NSNN Jump to Label_LOOP [65] {0:65}

                                                                                                                                            SSSN Push 0 [65,0]
                                                                                                                                            SNS Duplicate top (0) [65,0,0]
                                                                                                                                            TNTS Read STDIN as character [65,0] {0:50} 2
                                                                                                                                            TTT Retrieve at heap address (0) [65,50] {0:50}
                                                                                                                                            SNS Duplicate top (50) [65,50,50] {0:50}
                                                                                                                                            SSSTSTSN Push 10 [65,50,50,10] {0:50}
                                                                                                                                            TSST Subtract top two (50-10) [65,50,40] {0:50}
                                                                                                                                            NTSSN If 0: Jump to Label_PRINT [65,50] {0:50}
                                                                                                                                            NSNN Jump to Label_LOOP [65,50] {0:50}

                                                                                                                                            SSSN Push 0 [65,50,0]
                                                                                                                                            SNS Duplicate top (0) [65,50,0,0]
                                                                                                                                            TNTS Read STDIN as character [65,50,0] {0:35} #
                                                                                                                                            TTT Retrieve at heap address (0) [65,50,35] {0:35}
                                                                                                                                            SNS Duplicate top (35) [65,50,35,35] {0:35}
                                                                                                                                            SSSTSTSN Push 10 [65,50,35,35,10] {0:35}
                                                                                                                                            TSST Subtract top two (35-10) [65,50,35,25] {0:35}
                                                                                                                                            NTSSN If 0: Jump to Label_PRINT [65,50,35] {0:35}
                                                                                                                                            NSNN Jump to Label_LOOP [65,50,35] {0:35}

                                                                                                                                            SSSN Push 0 [65,50,35,0]
                                                                                                                                            SNS Duplicate top (0) [65,50,35,0,0]
                                                                                                                                            TNTS Read STDIN as character [65,50,35,0] {0:10} n
                                                                                                                                            TTT Retrieve at heap address (0) [65,50,35,10] {0:10}
                                                                                                                                            SNS Duplicate top (10) [65,50,35,10,10] {0:10}
                                                                                                                                            SSSTSTSN Push 10 [65,50,35,10,10,10] {0:10}
                                                                                                                                            TSST Subtract top two (10-10) [65,50,35,10,0] {0:10}
                                                                                                                                            NTSSN If 0: Jump to Label_PRINT [65,50,35,10] {0:10}

                                                                                                                                            NSSSN Create Label_PRINT [65,50,35,10] {0:10}
                                                                                                                                            SNN Discard top [65,50,35] {0:10}
                                                                                                                                            TNSS Print as character to STDOUT [65,50] {0:10} #
                                                                                                                                            {0:10} error


                                                                                                                                            Stops with the error: Exit not defined.






                                                                                                                                            share|improve this answer









                                                                                                                                            $endgroup$
















                                                                                                                                              1












                                                                                                                                              1








                                                                                                                                              1





                                                                                                                                              $begingroup$


                                                                                                                                              Whitespace, 54 bytes



                                                                                                                                              [N
                                                                                                                                              S S N
                                                                                                                                              _Create_Label_LOOP][S S S N
                                                                                                                                              _Push_0][S N
                                                                                                                                              S _Duplicate_0][T N
                                                                                                                                              T S _Read_STDIN_as_character][T T T _Retrieve_input][S N
                                                                                                                                              S _Duplicate][S S S T S T S N
                                                                                                                                              _Push_10][T S S T _Subtract][N
                                                                                                                                              T S S N
                                                                                                                                              _If_0_Jump_to_Label_PRINT][N
                                                                                                                                              S N
                                                                                                                                              N
                                                                                                                                              _Jump_to_Label_LOOP][N
                                                                                                                                              S S S N
                                                                                                                                              _Create_Label_PRINT][S N
                                                                                                                                              N
                                                                                                                                              _Discard_top][T N
                                                                                                                                              S S _Print_as_character]


                                                                                                                                              Letters S (space), T (tab), and N (new-line) added as highlighting only.
                                                                                                                                              [..._some_action] added as explanation only.



                                                                                                                                              Since Whitespace can only take input as integer or character, we must add a trailing character to indicate we're done with the input-string after reading it character by character, for which I've used a newline.



                                                                                                                                              Try it online (with raw spaces, tabs and new-lines only).



                                                                                                                                              Example run: input = A2#



                                                                                                                                              Command    Explanation                   Stack                Heap    STDIN STDOUT STDERR

                                                                                                                                              NSSN Create Label_LOOP
                                                                                                                                              SSSN Push 0 [0]
                                                                                                                                              SNS Duplicate top (0) [0,0]
                                                                                                                                              TNTS Read STDIN as character [0] {0:65} A
                                                                                                                                              TTT Retrieve at heap address (0) [65] {0:65}
                                                                                                                                              SNS Duplicate top (65) [65,65] {0:65}
                                                                                                                                              SSSTSTSN Push 10 [65,65,10] {0:65}
                                                                                                                                              TSST Subtract top two (65-10) [65,55] {0:65}
                                                                                                                                              NTSSN If 0: Jump to Label_PRINT [65] {0:65}
                                                                                                                                              NSNN Jump to Label_LOOP [65] {0:65}

                                                                                                                                              SSSN Push 0 [65,0]
                                                                                                                                              SNS Duplicate top (0) [65,0,0]
                                                                                                                                              TNTS Read STDIN as character [65,0] {0:50} 2
                                                                                                                                              TTT Retrieve at heap address (0) [65,50] {0:50}
                                                                                                                                              SNS Duplicate top (50) [65,50,50] {0:50}
                                                                                                                                              SSSTSTSN Push 10 [65,50,50,10] {0:50}
                                                                                                                                              TSST Subtract top two (50-10) [65,50,40] {0:50}
                                                                                                                                              NTSSN If 0: Jump to Label_PRINT [65,50] {0:50}
                                                                                                                                              NSNN Jump to Label_LOOP [65,50] {0:50}

                                                                                                                                              SSSN Push 0 [65,50,0]
                                                                                                                                              SNS Duplicate top (0) [65,50,0,0]
                                                                                                                                              TNTS Read STDIN as character [65,50,0] {0:35} #
                                                                                                                                              TTT Retrieve at heap address (0) [65,50,35] {0:35}
                                                                                                                                              SNS Duplicate top (35) [65,50,35,35] {0:35}
                                                                                                                                              SSSTSTSN Push 10 [65,50,35,35,10] {0:35}
                                                                                                                                              TSST Subtract top two (35-10) [65,50,35,25] {0:35}
                                                                                                                                              NTSSN If 0: Jump to Label_PRINT [65,50,35] {0:35}
                                                                                                                                              NSNN Jump to Label_LOOP [65,50,35] {0:35}

                                                                                                                                              SSSN Push 0 [65,50,35,0]
                                                                                                                                              SNS Duplicate top (0) [65,50,35,0,0]
                                                                                                                                              TNTS Read STDIN as character [65,50,35,0] {0:10} n
                                                                                                                                              TTT Retrieve at heap address (0) [65,50,35,10] {0:10}
                                                                                                                                              SNS Duplicate top (10) [65,50,35,10,10] {0:10}
                                                                                                                                              SSSTSTSN Push 10 [65,50,35,10,10,10] {0:10}
                                                                                                                                              TSST Subtract top two (10-10) [65,50,35,10,0] {0:10}
                                                                                                                                              NTSSN If 0: Jump to Label_PRINT [65,50,35,10] {0:10}

                                                                                                                                              NSSSN Create Label_PRINT [65,50,35,10] {0:10}
                                                                                                                                              SNN Discard top [65,50,35] {0:10}
                                                                                                                                              TNSS Print as character to STDOUT [65,50] {0:10} #
                                                                                                                                              {0:10} error


                                                                                                                                              Stops with the error: Exit not defined.






                                                                                                                                              share|improve this answer









                                                                                                                                              $endgroup$




                                                                                                                                              Whitespace, 54 bytes



                                                                                                                                              [N
                                                                                                                                              S S N
                                                                                                                                              _Create_Label_LOOP][S S S N
                                                                                                                                              _Push_0][S N
                                                                                                                                              S _Duplicate_0][T N
                                                                                                                                              T S _Read_STDIN_as_character][T T T _Retrieve_input][S N
                                                                                                                                              S _Duplicate][S S S T S T S N
                                                                                                                                              _Push_10][T S S T _Subtract][N
                                                                                                                                              T S S N
                                                                                                                                              _If_0_Jump_to_Label_PRINT][N
                                                                                                                                              S N
                                                                                                                                              N
                                                                                                                                              _Jump_to_Label_LOOP][N
                                                                                                                                              S S S N
                                                                                                                                              _Create_Label_PRINT][S N
                                                                                                                                              N
                                                                                                                                              _Discard_top][T N
                                                                                                                                              S S _Print_as_character]


                                                                                                                                              Letters S (space), T (tab), and N (new-line) added as highlighting only.
                                                                                                                                              [..._some_action] added as explanation only.



                                                                                                                                              Since Whitespace can only take input as integer or character, we must add a trailing character to indicate we're done with the input-string after reading it character by character, for which I've used a newline.



                                                                                                                                              Try it online (with raw spaces, tabs and new-lines only).



                                                                                                                                              Example run: input = A2#



                                                                                                                                              Command    Explanation                   Stack                Heap    STDIN STDOUT STDERR

                                                                                                                                              NSSN Create Label_LOOP
                                                                                                                                              SSSN Push 0 [0]
                                                                                                                                              SNS Duplicate top (0) [0,0]
                                                                                                                                              TNTS Read STDIN as character [0] {0:65} A
                                                                                                                                              TTT Retrieve at heap address (0) [65] {0:65}
                                                                                                                                              SNS Duplicate top (65) [65,65] {0:65}
                                                                                                                                              SSSTSTSN Push 10 [65,65,10] {0:65}
                                                                                                                                              TSST Subtract top two (65-10) [65,55] {0:65}
                                                                                                                                              NTSSN If 0: Jump to Label_PRINT [65] {0:65}
                                                                                                                                              NSNN Jump to Label_LOOP [65] {0:65}

                                                                                                                                              SSSN Push 0 [65,0]
                                                                                                                                              SNS Duplicate top (0) [65,0,0]
                                                                                                                                              TNTS Read STDIN as character [65,0] {0:50} 2
                                                                                                                                              TTT Retrieve at heap address (0) [65,50] {0:50}
                                                                                                                                              SNS Duplicate top (50) [65,50,50] {0:50}
                                                                                                                                              SSSTSTSN Push 10 [65,50,50,10] {0:50}
                                                                                                                                              TSST Subtract top two (50-10) [65,50,40] {0:50}
                                                                                                                                              NTSSN If 0: Jump to Label_PRINT [65,50] {0:50}
                                                                                                                                              NSNN Jump to Label_LOOP [65,50] {0:50}

                                                                                                                                              SSSN Push 0 [65,50,0]
                                                                                                                                              SNS Duplicate top (0) [65,50,0,0]
                                                                                                                                              TNTS Read STDIN as character [65,50,0] {0:35} #
                                                                                                                                              TTT Retrieve at heap address (0) [65,50,35] {0:35}
                                                                                                                                              SNS Duplicate top (35) [65,50,35,35] {0:35}
                                                                                                                                              SSSTSTSN Push 10 [65,50,35,35,10] {0:35}
                                                                                                                                              TSST Subtract top two (35-10) [65,50,35,25] {0:35}
                                                                                                                                              NTSSN If 0: Jump to Label_PRINT [65,50,35] {0:35}
                                                                                                                                              NSNN Jump to Label_LOOP [65,50,35] {0:35}

                                                                                                                                              SSSN Push 0 [65,50,35,0]
                                                                                                                                              SNS Duplicate top (0) [65,50,35,0,0]
                                                                                                                                              TNTS Read STDIN as character [65,50,35,0] {0:10} n
                                                                                                                                              TTT Retrieve at heap address (0) [65,50,35,10] {0:10}
                                                                                                                                              SNS Duplicate top (10) [65,50,35,10,10] {0:10}
                                                                                                                                              SSSTSTSN Push 10 [65,50,35,10,10,10] {0:10}
                                                                                                                                              TSST Subtract top two (10-10) [65,50,35,10,0] {0:10}
                                                                                                                                              NTSSN If 0: Jump to Label_PRINT [65,50,35,10] {0:10}

                                                                                                                                              NSSSN Create Label_PRINT [65,50,35,10] {0:10}
                                                                                                                                              SNN Discard top [65,50,35] {0:10}
                                                                                                                                              TNSS Print as character to STDOUT [65,50] {0:10} #
                                                                                                                                              {0:10} error


                                                                                                                                              Stops with the error: Exit not defined.







                                                                                                                                              share|improve this answer












                                                                                                                                              share|improve this answer



                                                                                                                                              share|improve this answer










                                                                                                                                              answered yesterday









                                                                                                                                              Kevin CruijssenKevin Cruijssen

                                                                                                                                              40.8k566210




                                                                                                                                              40.8k566210























                                                                                                                                                  1












                                                                                                                                                  $begingroup$

                                                                                                                                                  Turing Machine Code, 72 42 bytes



                                                                                                                                                  Assumes an input with no empty cells (spaces). Thanks to ASCII-only for saving 30 bytes.



                                                                                                                                                  0 * * r 1
                                                                                                                                                  1 * * l 2
                                                                                                                                                  1 _ _ l halt
                                                                                                                                                  2 * _ r 0


                                                                                                                                                  Old version in 72 bytes:



                                                                                                                                                  0 * * r 0
                                                                                                                                                  0 _ * l 1
                                                                                                                                                  1 * * l 2
                                                                                                                                                  2 * _ l 2
                                                                                                                                                  2 _ _ r 3
                                                                                                                                                  3 _ _ r 3
                                                                                                                                                  3 * * * halt


                                                                                                                                                  Try it online.






                                                                                                                                                  share|improve this answer











                                                                                                                                                  $endgroup$









                                                                                                                                                  • 1




                                                                                                                                                    $begingroup$
                                                                                                                                                    0 * * r 1/1 * * l 2/1 _ _ l halt/2 * _ r 0?
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday










                                                                                                                                                  • $begingroup$
                                                                                                                                                    oi pls reply :||
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday










                                                                                                                                                  • $begingroup$
                                                                                                                                                    wouldn't work in what way? I've tested it online
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday












                                                                                                                                                  • $begingroup$
                                                                                                                                                    @ASCII-only It turns out you're correct, and I was simply misinterpreting the way your program actually worked. I think it's different enough that you can post it as a different answer if you want to.
                                                                                                                                                    $endgroup$
                                                                                                                                                    – SuperJedi224
                                                                                                                                                    yesterday












                                                                                                                                                  • $begingroup$
                                                                                                                                                    Well, this is a simple challenge, don't think it needs more than one answer in any language :P
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday
















                                                                                                                                                  1












                                                                                                                                                  $begingroup$

                                                                                                                                                  Turing Machine Code, 72 42 bytes



                                                                                                                                                  Assumes an input with no empty cells (spaces). Thanks to ASCII-only for saving 30 bytes.



                                                                                                                                                  0 * * r 1
                                                                                                                                                  1 * * l 2
                                                                                                                                                  1 _ _ l halt
                                                                                                                                                  2 * _ r 0


                                                                                                                                                  Old version in 72 bytes:



                                                                                                                                                  0 * * r 0
                                                                                                                                                  0 _ * l 1
                                                                                                                                                  1 * * l 2
                                                                                                                                                  2 * _ l 2
                                                                                                                                                  2 _ _ r 3
                                                                                                                                                  3 _ _ r 3
                                                                                                                                                  3 * * * halt


                                                                                                                                                  Try it online.






                                                                                                                                                  share|improve this answer











                                                                                                                                                  $endgroup$









                                                                                                                                                  • 1




                                                                                                                                                    $begingroup$
                                                                                                                                                    0 * * r 1/1 * * l 2/1 _ _ l halt/2 * _ r 0?
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday










                                                                                                                                                  • $begingroup$
                                                                                                                                                    oi pls reply :||
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday










                                                                                                                                                  • $begingroup$
                                                                                                                                                    wouldn't work in what way? I've tested it online
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday












                                                                                                                                                  • $begingroup$
                                                                                                                                                    @ASCII-only It turns out you're correct, and I was simply misinterpreting the way your program actually worked. I think it's different enough that you can post it as a different answer if you want to.
                                                                                                                                                    $endgroup$
                                                                                                                                                    – SuperJedi224
                                                                                                                                                    yesterday












                                                                                                                                                  • $begingroup$
                                                                                                                                                    Well, this is a simple challenge, don't think it needs more than one answer in any language :P
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday














                                                                                                                                                  1












                                                                                                                                                  1








                                                                                                                                                  1





                                                                                                                                                  $begingroup$

                                                                                                                                                  Turing Machine Code, 72 42 bytes



                                                                                                                                                  Assumes an input with no empty cells (spaces). Thanks to ASCII-only for saving 30 bytes.



                                                                                                                                                  0 * * r 1
                                                                                                                                                  1 * * l 2
                                                                                                                                                  1 _ _ l halt
                                                                                                                                                  2 * _ r 0


                                                                                                                                                  Old version in 72 bytes:



                                                                                                                                                  0 * * r 0
                                                                                                                                                  0 _ * l 1
                                                                                                                                                  1 * * l 2
                                                                                                                                                  2 * _ l 2
                                                                                                                                                  2 _ _ r 3
                                                                                                                                                  3 _ _ r 3
                                                                                                                                                  3 * * * halt


                                                                                                                                                  Try it online.






                                                                                                                                                  share|improve this answer











                                                                                                                                                  $endgroup$



                                                                                                                                                  Turing Machine Code, 72 42 bytes



                                                                                                                                                  Assumes an input with no empty cells (spaces). Thanks to ASCII-only for saving 30 bytes.



                                                                                                                                                  0 * * r 1
                                                                                                                                                  1 * * l 2
                                                                                                                                                  1 _ _ l halt
                                                                                                                                                  2 * _ r 0


                                                                                                                                                  Old version in 72 bytes:



                                                                                                                                                  0 * * r 0
                                                                                                                                                  0 _ * l 1
                                                                                                                                                  1 * * l 2
                                                                                                                                                  2 * _ l 2
                                                                                                                                                  2 _ _ r 3
                                                                                                                                                  3 _ _ r 3
                                                                                                                                                  3 * * * halt


                                                                                                                                                  Try it online.







                                                                                                                                                  share|improve this answer














                                                                                                                                                  share|improve this answer



                                                                                                                                                  share|improve this answer








                                                                                                                                                  edited yesterday

























                                                                                                                                                  answered yesterday









                                                                                                                                                  SuperJedi224SuperJedi224

                                                                                                                                                  9,86013363




                                                                                                                                                  9,86013363








                                                                                                                                                  • 1




                                                                                                                                                    $begingroup$
                                                                                                                                                    0 * * r 1/1 * * l 2/1 _ _ l halt/2 * _ r 0?
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday










                                                                                                                                                  • $begingroup$
                                                                                                                                                    oi pls reply :||
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday










                                                                                                                                                  • $begingroup$
                                                                                                                                                    wouldn't work in what way? I've tested it online
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday












                                                                                                                                                  • $begingroup$
                                                                                                                                                    @ASCII-only It turns out you're correct, and I was simply misinterpreting the way your program actually worked. I think it's different enough that you can post it as a different answer if you want to.
                                                                                                                                                    $endgroup$
                                                                                                                                                    – SuperJedi224
                                                                                                                                                    yesterday












                                                                                                                                                  • $begingroup$
                                                                                                                                                    Well, this is a simple challenge, don't think it needs more than one answer in any language :P
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday














                                                                                                                                                  • 1




                                                                                                                                                    $begingroup$
                                                                                                                                                    0 * * r 1/1 * * l 2/1 _ _ l halt/2 * _ r 0?
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday










                                                                                                                                                  • $begingroup$
                                                                                                                                                    oi pls reply :||
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday










                                                                                                                                                  • $begingroup$
                                                                                                                                                    wouldn't work in what way? I've tested it online
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday












                                                                                                                                                  • $begingroup$
                                                                                                                                                    @ASCII-only It turns out you're correct, and I was simply misinterpreting the way your program actually worked. I think it's different enough that you can post it as a different answer if you want to.
                                                                                                                                                    $endgroup$
                                                                                                                                                    – SuperJedi224
                                                                                                                                                    yesterday












                                                                                                                                                  • $begingroup$
                                                                                                                                                    Well, this is a simple challenge, don't think it needs more than one answer in any language :P
                                                                                                                                                    $endgroup$
                                                                                                                                                    – ASCII-only
                                                                                                                                                    yesterday








                                                                                                                                                  1




                                                                                                                                                  1




                                                                                                                                                  $begingroup$
                                                                                                                                                  0 * * r 1/1 * * l 2/1 _ _ l halt/2 * _ r 0?
                                                                                                                                                  $endgroup$
                                                                                                                                                  – ASCII-only
                                                                                                                                                  yesterday




                                                                                                                                                  $begingroup$
                                                                                                                                                  0 * * r 1/1 * * l 2/1 _ _ l halt/2 * _ r 0?
                                                                                                                                                  $endgroup$
                                                                                                                                                  – ASCII-only
                                                                                                                                                  yesterday












                                                                                                                                                  $begingroup$
                                                                                                                                                  oi pls reply :||
                                                                                                                                                  $endgroup$
                                                                                                                                                  – ASCII-only
                                                                                                                                                  yesterday




                                                                                                                                                  $begingroup$
                                                                                                                                                  oi pls reply :||
                                                                                                                                                  $endgroup$
                                                                                                                                                  – ASCII-only
                                                                                                                                                  yesterday












                                                                                                                                                  $begingroup$
                                                                                                                                                  wouldn't work in what way? I've tested it online
                                                                                                                                                  $endgroup$
                                                                                                                                                  – ASCII-only
                                                                                                                                                  yesterday






                                                                                                                                                  $begingroup$
                                                                                                                                                  wouldn't work in what way? I've tested it online
                                                                                                                                                  $endgroup$
                                                                                                                                                  – ASCII-only
                                                                                                                                                  yesterday














                                                                                                                                                  $begingroup$
                                                                                                                                                  @ASCII-only It turns out you're correct, and I was simply misinterpreting the way your program actually worked. I think it's different enough that you can post it as a different answer if you want to.
                                                                                                                                                  $endgroup$
                                                                                                                                                  – SuperJedi224
                                                                                                                                                  yesterday






                                                                                                                                                  $begingroup$
                                                                                                                                                  @ASCII-only It turns out you're correct, and I was simply misinterpreting the way your program actually worked. I think it's different enough that you can post it as a different answer if you want to.
                                                                                                                                                  $endgroup$
                                                                                                                                                  – SuperJedi224
                                                                                                                                                  yesterday














                                                                                                                                                  $begingroup$
                                                                                                                                                  Well, this is a simple challenge, don't think it needs more than one answer in any language :P
                                                                                                                                                  $endgroup$
                                                                                                                                                  – ASCII-only
                                                                                                                                                  yesterday




                                                                                                                                                  $begingroup$
                                                                                                                                                  Well, this is a simple challenge, don't think it needs more than one answer in any language :P
                                                                                                                                                  $endgroup$
                                                                                                                                                  – ASCII-only
                                                                                                                                                  yesterday











                                                                                                                                                  1












                                                                                                                                                  $begingroup$


                                                                                                                                                  R, 35 bytes



                                                                                                                                                  Takes the input, splits it in to a list, outputs the last element of the list.





                                                                                                                                                  tail(strsplit(scan(,''),'')[[1]],1)


                                                                                                                                                  Try it online!






                                                                                                                                                  share|improve this answer









                                                                                                                                                  $endgroup$


















                                                                                                                                                    1












                                                                                                                                                    $begingroup$


                                                                                                                                                    R, 35 bytes



                                                                                                                                                    Takes the input, splits it in to a list, outputs the last element of the list.





                                                                                                                                                    tail(strsplit(scan(,''),'')[[1]],1)


                                                                                                                                                    Try it online!






                                                                                                                                                    share|improve this answer









                                                                                                                                                    $endgroup$
















                                                                                                                                                      1












                                                                                                                                                      1








                                                                                                                                                      1





                                                                                                                                                      $begingroup$


                                                                                                                                                      R, 35 bytes



                                                                                                                                                      Takes the input, splits it in to a list, outputs the last element of the list.





                                                                                                                                                      tail(strsplit(scan(,''),'')[[1]],1)


                                                                                                                                                      Try it online!






                                                                                                                                                      share|improve this answer









                                                                                                                                                      $endgroup$




                                                                                                                                                      R, 35 bytes



                                                                                                                                                      Takes the input, splits it in to a list, outputs the last element of the list.





                                                                                                                                                      tail(strsplit(scan(,''),'')[[1]],1)


                                                                                                                                                      Try it online!







                                                                                                                                                      share|improve this answer












                                                                                                                                                      share|improve this answer



                                                                                                                                                      share|improve this answer










                                                                                                                                                      answered yesterday









                                                                                                                                                      CT HallCT Hall

                                                                                                                                                      42110




                                                                                                                                                      42110























                                                                                                                                                          1












                                                                                                                                                          $begingroup$


                                                                                                                                                          INTERCAL, 270 bytes



                                                                                                                                                          DO,1<-#1PLEASECOMEFROM(2)DOWRITEIN,1DO.1<-,1SUB#1DO.5<-#1$!1~#256'DO.2<-.3DO(1)NEXTPLEASE.2<-'"!3~#1'$!3~#16'"$"!3~#4'$!3~#64'"'$'"!3~#2'$!3~#32'"$"!3~#8'$!3~#128'"'DO(1010)NEXTPLEASE,1SUB#1<-.3PLEASEREADOUT,1DOGIVEUP(1)DO(1002)NEXTDO(1009)NEXTDO.3<-.3~#255(2)DOFORGET#1


                                                                                                                                                          Try it online!



                                                                                                                                                          Writing this was... interesting. I was thinking I might want to use INTERCAL to INTERCALate, but I'm a bit less sure now.



                                                                                                                                                          Ungolfed and commented:



                                                                                                                                                                  DO ,1<-#1             PLEASE NOTE We want the input array to only have space for one element, so it will only take one at a time
                                                                                                                                                          DO COME FROM (2)
                                                                                                                                                          DO WRITE IN ,1 PLEASE NOTE If this is the first byte of the input, it'll write its value... but if not, it'll write the
                                                                                                                                                          previous value minus its value mod 256.
                                                                                                                                                          DO .1<-,1SUB#1
                                                                                                                                                          DO .5<-#1$!1~#256' PLEASE NOTE .5 is 3 if the input is 256, 2 otherwise
                                                                                                                                                          DO .2<-.3
                                                                                                                                                          DO (1) NEXT

                                                                                                                                                          PLEASE NOTE If we're here, we've found the end of the input. Now, we need to print it back out... C-INTERCAL's
                                                                                                                                                          array I/O, in order to determine what it will actually print, subtracts the value it's going to print from the
                                                                                                                                                          previous one (still mod 256, and with the previous value defaulting to 0), and then reads the bits of the byte
                                                                                                                                                          backwards. So in order to go from the value we want to display to the value we need to feed into READ OUT, we
                                                                                                                                                          reverse the bits and then subtract from 256. The nightmarish expression on the following line reverses the
                                                                                                                                                          bits the best way I could think to: individually select each one out and then mingle them all back
                                                                                                                                                          together. It may be possible to emulate the method used in cesspool.c, by using mingle and unary AND as a
                                                                                                                                                          substitute for binary AND where we can't afford for select to rearrange it, but it might end up longer...

                                                                                                                                                          DO .2 <- '"'.3~#1'$'.3~#16'"$"'.3~#4'$'.3~#64'"'$'"'.3~#2'$'.3~#32'"$"'.3~#8'$'.3~#128'"'

                                                                                                                                                          DO (1010) NEXT PLEASE NOTE .1 already has 256 in it, which is very convenient for when you need to subtract .2 from 256.

                                                                                                                                                          DO ,1SUB#1 <- .3 PLEASE NOTE If we just read .3 out, we'd get a Roman numeral instead of the correct output.
                                                                                                                                                          DO READ OUT ,1

                                                                                                                                                          DO GIVE UP PLEASE NOTE End of program.

                                                                                                                                                          (1) DO (1002) NEXT PLEASE NOTE that that line in syslib does 1001 next, which pops .5 entries off the next-stack and returns
                                                                                                                                                          control flow to the last one, such that if .5 is 2 flow will come back here, but if it's 3 then it'll go back
                                                                                                                                                          to the line that nexted to this one.

                                                                                                                                                          Here we add .1 and .2 into .3, then truncate it to a byte before looping back (while managing the next-stack
                                                                                                                                                          responsibly so the program doesn't disappear into the black lagoon for any input over 79 (?) bytes)

                                                                                                                                                          DO (1009) NEXT
                                                                                                                                                          DO .3<-.3~#255
                                                                                                                                                          (2) DO FORGET #1





                                                                                                                                                          share|improve this answer











                                                                                                                                                          $endgroup$


















                                                                                                                                                            1












                                                                                                                                                            $begingroup$


                                                                                                                                                            INTERCAL, 270 bytes



                                                                                                                                                            DO,1<-#1PLEASECOMEFROM(2)DOWRITEIN,1DO.1<-,1SUB#1DO.5<-#1$!1~#256'DO.2<-.3DO(1)NEXTPLEASE.2<-'"!3~#1'$!3~#16'"$"!3~#4'$!3~#64'"'$'"!3~#2'$!3~#32'"$"!3~#8'$!3~#128'"'DO(1010)NEXTPLEASE,1SUB#1<-.3PLEASEREADOUT,1DOGIVEUP(1)DO(1002)NEXTDO(1009)NEXTDO.3<-.3~#255(2)DOFORGET#1


                                                                                                                                                            Try it online!



                                                                                                                                                            Writing this was... interesting. I was thinking I might want to use INTERCAL to INTERCALate, but I'm a bit less sure now.



                                                                                                                                                            Ungolfed and commented:



                                                                                                                                                                    DO ,1<-#1             PLEASE NOTE We want the input array to only have space for one element, so it will only take one at a time
                                                                                                                                                            DO COME FROM (2)
                                                                                                                                                            DO WRITE IN ,1 PLEASE NOTE If this is the first byte of the input, it'll write its value... but if not, it'll write the
                                                                                                                                                            previous value minus its value mod 256.
                                                                                                                                                            DO .1<-,1SUB#1
                                                                                                                                                            DO .5<-#1$!1~#256' PLEASE NOTE .5 is 3 if the input is 256, 2 otherwise
                                                                                                                                                            DO .2<-.3
                                                                                                                                                            DO (1) NEXT

                                                                                                                                                            PLEASE NOTE If we're here, we've found the end of the input. Now, we need to print it back out... C-INTERCAL's
                                                                                                                                                            array I/O, in order to determine what it will actually print, subtracts the value it's going to print from the
                                                                                                                                                            previous one (still mod 256, and with the previous value defaulting to 0), and then reads the bits of the byte
                                                                                                                                                            backwards. So in order to go from the value we want to display to the value we need to feed into READ OUT, we
                                                                                                                                                            reverse the bits and then subtract from 256. The nightmarish expression on the following line reverses the
                                                                                                                                                            bits the best way I could think to: individually select each one out and then mingle them all back
                                                                                                                                                            together. It may be possible to emulate the method used in cesspool.c, by using mingle and unary AND as a
                                                                                                                                                            substitute for binary AND where we can't afford for select to rearrange it, but it might end up longer...

                                                                                                                                                            DO .2 <- '"'.3~#1'$'.3~#16'"$"'.3~#4'$'.3~#64'"'$'"'.3~#2'$'.3~#32'"$"'.3~#8'$'.3~#128'"'

                                                                                                                                                            DO (1010) NEXT PLEASE NOTE .1 already has 256 in it, which is very convenient for when you need to subtract .2 from 256.

                                                                                                                                                            DO ,1SUB#1 <- .3 PLEASE NOTE If we just read .3 out, we'd get a Roman numeral instead of the correct output.
                                                                                                                                                            DO READ OUT ,1

                                                                                                                                                            DO GIVE UP PLEASE NOTE End of program.

                                                                                                                                                            (1) DO (1002) NEXT PLEASE NOTE that that line in syslib does 1001 next, which pops .5 entries off the next-stack and returns
                                                                                                                                                            control flow to the last one, such that if .5 is 2 flow will come back here, but if it's 3 then it'll go back
                                                                                                                                                            to the line that nexted to this one.

                                                                                                                                                            Here we add .1 and .2 into .3, then truncate it to a byte before looping back (while managing the next-stack
                                                                                                                                                            responsibly so the program doesn't disappear into the black lagoon for any input over 79 (?) bytes)

                                                                                                                                                            DO (1009) NEXT
                                                                                                                                                            DO .3<-.3~#255
                                                                                                                                                            (2) DO FORGET #1





                                                                                                                                                            share|improve this answer











                                                                                                                                                            $endgroup$
















                                                                                                                                                              1












                                                                                                                                                              1








                                                                                                                                                              1





                                                                                                                                                              $begingroup$


                                                                                                                                                              INTERCAL, 270 bytes



                                                                                                                                                              DO,1<-#1PLEASECOMEFROM(2)DOWRITEIN,1DO.1<-,1SUB#1DO.5<-#1$!1~#256'DO.2<-.3DO(1)NEXTPLEASE.2<-'"!3~#1'$!3~#16'"$"!3~#4'$!3~#64'"'$'"!3~#2'$!3~#32'"$"!3~#8'$!3~#128'"'DO(1010)NEXTPLEASE,1SUB#1<-.3PLEASEREADOUT,1DOGIVEUP(1)DO(1002)NEXTDO(1009)NEXTDO.3<-.3~#255(2)DOFORGET#1


                                                                                                                                                              Try it online!



                                                                                                                                                              Writing this was... interesting. I was thinking I might want to use INTERCAL to INTERCALate, but I'm a bit less sure now.



                                                                                                                                                              Ungolfed and commented:



                                                                                                                                                                      DO ,1<-#1             PLEASE NOTE We want the input array to only have space for one element, so it will only take one at a time
                                                                                                                                                              DO COME FROM (2)
                                                                                                                                                              DO WRITE IN ,1 PLEASE NOTE If this is the first byte of the input, it'll write its value... but if not, it'll write the
                                                                                                                                                              previous value minus its value mod 256.
                                                                                                                                                              DO .1<-,1SUB#1
                                                                                                                                                              DO .5<-#1$!1~#256' PLEASE NOTE .5 is 3 if the input is 256, 2 otherwise
                                                                                                                                                              DO .2<-.3
                                                                                                                                                              DO (1) NEXT

                                                                                                                                                              PLEASE NOTE If we're here, we've found the end of the input. Now, we need to print it back out... C-INTERCAL's
                                                                                                                                                              array I/O, in order to determine what it will actually print, subtracts the value it's going to print from the
                                                                                                                                                              previous one (still mod 256, and with the previous value defaulting to 0), and then reads the bits of the byte
                                                                                                                                                              backwards. So in order to go from the value we want to display to the value we need to feed into READ OUT, we
                                                                                                                                                              reverse the bits and then subtract from 256. The nightmarish expression on the following line reverses the
                                                                                                                                                              bits the best way I could think to: individually select each one out and then mingle them all back
                                                                                                                                                              together. It may be possible to emulate the method used in cesspool.c, by using mingle and unary AND as a
                                                                                                                                                              substitute for binary AND where we can't afford for select to rearrange it, but it might end up longer...

                                                                                                                                                              DO .2 <- '"'.3~#1'$'.3~#16'"$"'.3~#4'$'.3~#64'"'$'"'.3~#2'$'.3~#32'"$"'.3~#8'$'.3~#128'"'

                                                                                                                                                              DO (1010) NEXT PLEASE NOTE .1 already has 256 in it, which is very convenient for when you need to subtract .2 from 256.

                                                                                                                                                              DO ,1SUB#1 <- .3 PLEASE NOTE If we just read .3 out, we'd get a Roman numeral instead of the correct output.
                                                                                                                                                              DO READ OUT ,1

                                                                                                                                                              DO GIVE UP PLEASE NOTE End of program.

                                                                                                                                                              (1) DO (1002) NEXT PLEASE NOTE that that line in syslib does 1001 next, which pops .5 entries off the next-stack and returns
                                                                                                                                                              control flow to the last one, such that if .5 is 2 flow will come back here, but if it's 3 then it'll go back
                                                                                                                                                              to the line that nexted to this one.

                                                                                                                                                              Here we add .1 and .2 into .3, then truncate it to a byte before looping back (while managing the next-stack
                                                                                                                                                              responsibly so the program doesn't disappear into the black lagoon for any input over 79 (?) bytes)

                                                                                                                                                              DO (1009) NEXT
                                                                                                                                                              DO .3<-.3~#255
                                                                                                                                                              (2) DO FORGET #1





                                                                                                                                                              share|improve this answer











                                                                                                                                                              $endgroup$




                                                                                                                                                              INTERCAL, 270 bytes



                                                                                                                                                              DO,1<-#1PLEASECOMEFROM(2)DOWRITEIN,1DO.1<-,1SUB#1DO.5<-#1$!1~#256'DO.2<-.3DO(1)NEXTPLEASE.2<-'"!3~#1'$!3~#16'"$"!3~#4'$!3~#64'"'$'"!3~#2'$!3~#32'"$"!3~#8'$!3~#128'"'DO(1010)NEXTPLEASE,1SUB#1<-.3PLEASEREADOUT,1DOGIVEUP(1)DO(1002)NEXTDO(1009)NEXTDO.3<-.3~#255(2)DOFORGET#1


                                                                                                                                                              Try it online!



                                                                                                                                                              Writing this was... interesting. I was thinking I might want to use INTERCAL to INTERCALate, but I'm a bit less sure now.



                                                                                                                                                              Ungolfed and commented:



                                                                                                                                                                      DO ,1<-#1             PLEASE NOTE We want the input array to only have space for one element, so it will only take one at a time
                                                                                                                                                              DO COME FROM (2)
                                                                                                                                                              DO WRITE IN ,1 PLEASE NOTE If this is the first byte of the input, it'll write its value... but if not, it'll write the
                                                                                                                                                              previous value minus its value mod 256.
                                                                                                                                                              DO .1<-,1SUB#1
                                                                                                                                                              DO .5<-#1$!1~#256' PLEASE NOTE .5 is 3 if the input is 256, 2 otherwise
                                                                                                                                                              DO .2<-.3
                                                                                                                                                              DO (1) NEXT

                                                                                                                                                              PLEASE NOTE If we're here, we've found the end of the input. Now, we need to print it back out... C-INTERCAL's
                                                                                                                                                              array I/O, in order to determine what it will actually print, subtracts the value it's going to print from the
                                                                                                                                                              previous one (still mod 256, and with the previous value defaulting to 0), and then reads the bits of the byte
                                                                                                                                                              backwards. So in order to go from the value we want to display to the value we need to feed into READ OUT, we
                                                                                                                                                              reverse the bits and then subtract from 256. The nightmarish expression on the following line reverses the
                                                                                                                                                              bits the best way I could think to: individually select each one out and then mingle them all back
                                                                                                                                                              together. It may be possible to emulate the method used in cesspool.c, by using mingle and unary AND as a
                                                                                                                                                              substitute for binary AND where we can't afford for select to rearrange it, but it might end up longer...

                                                                                                                                                              DO .2 <- '"'.3~#1'$'.3~#16'"$"'.3~#4'$'.3~#64'"'$'"'.3~#2'$'.3~#32'"$"'.3~#8'$'.3~#128'"'

                                                                                                                                                              DO (1010) NEXT PLEASE NOTE .1 already has 256 in it, which is very convenient for when you need to subtract .2 from 256.

                                                                                                                                                              DO ,1SUB#1 <- .3 PLEASE NOTE If we just read .3 out, we'd get a Roman numeral instead of the correct output.
                                                                                                                                                              DO READ OUT ,1

                                                                                                                                                              DO GIVE UP PLEASE NOTE End of program.

                                                                                                                                                              (1) DO (1002) NEXT PLEASE NOTE that that line in syslib does 1001 next, which pops .5 entries off the next-stack and returns
                                                                                                                                                              control flow to the last one, such that if .5 is 2 flow will come back here, but if it's 3 then it'll go back
                                                                                                                                                              to the line that nexted to this one.

                                                                                                                                                              Here we add .1 and .2 into .3, then truncate it to a byte before looping back (while managing the next-stack
                                                                                                                                                              responsibly so the program doesn't disappear into the black lagoon for any input over 79 (?) bytes)

                                                                                                                                                              DO (1009) NEXT
                                                                                                                                                              DO .3<-.3~#255
                                                                                                                                                              (2) DO FORGET #1






                                                                                                                                                              share|improve this answer














                                                                                                                                                              share|improve this answer



                                                                                                                                                              share|improve this answer








                                                                                                                                                              edited 13 hours ago

























                                                                                                                                                              answered 14 hours ago









                                                                                                                                                              Unrelated StringUnrelated String

                                                                                                                                                              1,241110




                                                                                                                                                              1,241110






















                                                                                                                                                                  1 2
                                                                                                                                                                  next









                                                                                                                                                                  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

                                                                                                                                                                  Plaza Victoria

                                                                                                                                                                  Brian Clough

                                                                                                                                                                  Cáceres