[Question]
  [
**Requirements:**
* Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.)
* Output the reverse of the input on stdout.
**Example:**
Input:
```
Quick brown fox
He jumped over the lazy dog
```
Output:
```
god yzal eht revo depmuj eH
xof nworb kciuQ
```
Shortest wins.
Leaderboard:
```
var QUESTION_ID=242,OVERRIDE_USER=61563;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
  
[Answer]
## Bash - 7
```
tac|rev
```
`tac` reverses line order, while `rev` reverses character order.
[Answer]
## BrainFuck, 10 characters
```
,[>,]<[.<]
```
Beats a good amount of answers for such a simple language.
[Answer]
## Golfscript - 3 chars
```
-1%
```
obfuscated version is also 3 chars
```
0(%
```
[here](http://www.golfscript.com/golfscript/builtin.html#%) is an explanation of how [%](http://www.golfscript.com/golfscript/builtin.html#%) works
[Answer]
## C, 37 bytes
```
main(_){write(read(0,&_,1)&&main());}
```
[Answer]
# Haskell - 21
```
main=interact reverse
```
[Answer]
# [Pancake Stack](http://esolangs.org/wiki/Pancake_Stack), ~~342~~ 316 bytes
```
Put this nice pancake on top!
[]
Put this  pancake on top!
How about a hotcake?
If the pancake is tasty, go over to "".
Put this delightful pancake on top!
[#]
Eat the pancake on top!
Eat the pancake on top!
Show me a pancake!
Eat the pancake on top!
If the pancake is tasty, go over to "#".
Eat all of the pancakes!
```
It assumes that the input is terminated by a null character (`^@` on commandline). Example run, using the [interpreter](http://ideone.com/7sFFo0):
```
Put this nice pancake on top!
[]
Put this  pancake on top!
How about a hotcake?
If the pancake is tasty, go over to "".
Put this delightful pancake on top!
[#]
Eat the pancake on top!
Eat the pancake on top!
Show me a pancake!
Eat the pancake on top!
If the pancake is tasty, go over to "#".
Eat all of the pancakes!
~~~~~~~~~~~~~~~~~~~~~~~~
Hello, World!^@
!dlroW ,olleH
```
[Answer]
# Python, 41 40 bytes
```
import sys;print sys.stdin.read()[::-1]
```
41 -> 40 - removed semicolon at end of program.
Probably could be optimised!
[Answer]
## APL, 2
```
⊖⍞
```
Or CircleBar QuoteQuad if the characters don't come through, simply meaning: reverse keyboard character input.
[Answer]
## Perl - 23
```
print scalar reverse <>
```
[Answer]
# C - 47 characters
```
main(c){if(c=getchar(),c>=0)main(),putchar(c);}
```
Note that this uses O(n) stack space. [Try it online!](https://tio.run/##S9ZNT07@/z83MTNPI1mzOjNNI9k2PbUkOSOxSENTJ9nO1kATLKepU1AKEU3WtK79/x8A)
[Answer]
## Ruby - 19 characters
```
puts$<.read.reverse
```
[Answer]
### Windows PowerShell, 53 ~~54~~
```
-join($x=[char[]]($($input)-join'
'))[($x.count)..0]
```
**2011-01-30** (54) – First attempt
**2011-01-30** (53) – Inline line breaks are fun.
**2011-01-3-** (52) – Inlined variable assignments too.
[Answer]
# Binary Lambda Calculus - 9 bytes
```
16 46 80 17 3E F0 B7 B0 40
```
Source: <http://ioccc.org/2012/tromp/hint.html>
[Answer]
## Perl 5.1, 14
```
say~~reverse<>
```
[Answer]
## Befunge-93 - 11x2 (22 characters)
```
>~:0`v >:v
^    _$^,_@
```
Tested using [this interpreter](http://www.quirkster.com/iano/js/befunge.html).
[Answer]
## ><>, ~~16~~ 14 bytes
### -2 bytes by @JoKing
two years (!) later, removes the extra -1 from reading input by shifting around the logic for halting.
```
i:0(7$.
0=?;ol
```
[Try it online!](https://tio.run/##S8sszvj/P9PKQMNcRY/LwNbeOj/n///yxKKknFQurqzivJTsxOKsFAA)
Similar to the other ><> answer, this doesn't need to reverse the stack because of the way input is read in the first line. I'm actually not too sure whether or not this should be a suggestion for the other ><> answer, as it is quite different in appearance but similar in concept.
The main difference is that my answer compares the input to 0, and if it is less (i.e. there is no input -- `i` returns -1 if there is no input) it jumps to (1,7), if not, (0,7). If it jumps to the former, it pops the top value (-1) and starts a print loop. If it jumps to the latter, it continues the input loop.
# 11 bytes, exits with an error
### Courtesy of @JoKing
```
i:0(7$.
~o!
```
[Try it online!](https://tio.run/##S8sszvj/P9PKQMNcRY@rLl/x///yxKKknFQurqzivJTsxOKsFAA)
I believe this is valid now via meta consensus.
# Previous answer (14 bytes)
```
i:0(7$.
~ol0=?;!
```
[Answer]
# [Fission](http://esolangs.org/wiki/Fission), ~~16~~ ~~14~~ 12 bytes
```
DY$\
?
[Z~K!
```
## Explanation
Control flow starts at `D` with a down-going `(1,0)` atom. The `?` reads from STDIN, one character at a time, setting the mass to the read character code and the energy to `0`. Once we hit EOF, `?` will instead set the energy to `1`. The `[` redirects the atom onto a `Z` switch. As long as we're reading characters, the energy will be `0`, so the atom is deflected to the upwards by the `Z`. We clone the atom, looping one copy back into the `?` to keep reading input. We increment the other copy's energy to `1` with `$` and push it onto the stack `K`. So the input loop is this:
```
DY$\
?
[Z K
```
When the energy is `1` due to EOF, the `Z` will instead let the atom pass straight through and decrement the energy to `0` again. `~` decrements the energy further to `-1`. Atoms with negative energy *pop* from the stack, so we can retrieve the characters in opposite order and print them with `!`. Now note that the grid is toroidal, so the atom reappears on the left edge of the same row. Remember that we incremented the energy of the pushed atoms earlier with `$`, so the atoms now have energy `1` just like the last output from `?` and will again pass straight through the `Z`. The path after EOF is therefore
```
?
[Z~K!
```
This loop on the bottom row continues until the stack is empty. When that happens, the atom is reflected back from the `K` and its energy becomes positive (`+1`). The `~` decrements it once more (moving to the left), so that we now hit the `Z` with non-positive energy. This deflects the atom downward, such that it ends up in the wedge of `Y` where it's stored, and because there are no more moving atoms, the program terminates.
[Answer]
## [Stack Cats](https://github.com/mbuettner/stackcats), 7 bytes
```
<!]T[!>
```
[Try it online!](http://stackcats.tryitonline.net/#code=PCFdVFshPg&input=YWJjCmRlZgowMTI)
There's a bunch of alternatives for the same byte count, most of which are essentially equivalent in how they work:
### Explanation
A short Stack Cats primer:
* Every program has to have mirror symmetry, and by mirroring any piece of code we obtain new code which computes the inverse function. Therefore the last three characters of the program above undo the first three, if it wasn't for the command in the centre.
* The memory model is an infinite tape of stacks, which hold an implicit, infinite amount of zeros at the bottom. The initial stack has a `-1` on top of those zeros and then the input bytes on top of that (with the first byte at the very top and the last byte above the `-1`).
* For output, we simply take the final stack, discard a `-1` at the bottom if there is one, and then print all the values as bytes to STDOUT.
Now for the actual program:
```
<    Move the tape head one stack left (onto an empty stack).
!    Bitwise NOT of the implicit zero on top, giving -1.
]    Move back to the original stack, taking the -1 with the tape head.
     We're now back to the original situation, except that we have a -1
     on top.
T    Reverse the stack down to the -1 at the bottom. One of the reasons
     we needed to move a -1 on top is that T only works when the top of
     the stack is nonzero. Since the first byte of the input could have
     been a null-byte we need the -1 to make sure this does anything at
     all.
[    Push the -1 to the stack on the left.
!    Bitwise NOT, turning it back into 0 (this is irrelevant).
>    Move the tape head back onto the original stack.
```
Sp3000 set his brute force search to find all other 7-byte solutions, so here are some alternatives:
```
<]!T![>
>![T]!<
>[!T!]<
```
These three variants are essentially the same, except that they differ in when the bitwise NOT is computed and whether we use the empty stack on the left or on the right.
```
<]T!T[>
>[T!T]<
```
Like I said in the explanation above, `T` doesn't do anything when the top of the stack is zero. That means we can actually put the `!` in the middle instead. That means the first `T` is a no-op, then we turn the zero on top into a `-1` and *then* then second `T` performs the reversal. Of course, this means that the final memory state has a `-1` on the stack next to the original one, but that doesn't matter since only the stack at the current tape head position affects the output.
```
<*ITI*>
```
This variant uses `*` (XOR 1) instead of `!`, so that it turns the zero into `+1`, and the `I` is a conditional push which pushes positive values and right, negative values left, and negates them in either case (such that we still end up with a `-1` on top of the original stack when we encounter `T`), so this ultimately works the same as the original `<!]T[!>` solution.
[Answer]
# PHP - ~~38~~ 17 characters
```
<?=strrev(`cat`);
```
[Answer]
# [Fuzzy Octo Guacamole](https://github.com/RikerW/Fuzzy-Octo-Guacamole), 2 bytes
(non-competing, FOG is newer than the challenge)
```
^z
```
`^` gets input, `z` reverses, and implicit output.
[Answer]
# [Hexagony](https://github.com/m-ender/hexagony), 16 bytes
```
\{\{:}($.,.=;)$\
```
[Try it online!](https://tio.run/##y0itSEzPz6v8/z@mOqbaqlZDRU9Hz9ZaUyXm/3/FlJyi/HCF/JycVA8A "Hexagony – Try It Online")
Expanded: (Made with [Hexagony Colorer](https://github.com/Timwi/HexagonyColorer))
[![Reverse Cat in Hexagony](https://i.stack.imgur.com/R9eRu.png)](https://i.stack.imgur.com/R9eRu.png)
Explanation:
* Blue path moves IP to the red path
* Red path moves "forward" in memory, reads a byte from STDIN, and increments it by 1, then checks if it's positive. The increment is so that the check will pass for all values including null bytes, and only fail for EOF (which Hexagony reads as negative 1)
* Orange path is reached when the check fails, it reverses memory and then puts the IP on the green path
* Green path goes back through the memory, attempting to divide 0 by each byte in memory. If the byte is empty, the end of the string has been reached, and the program crashes attempting to divide by zero. Otherwise it decrements the byte by 1 (to undo the increment from before) and prints it as a character.
Alternative 21 byte solutions that properly terminate instead of crashing:
`\{}\(//,;./')"<$|/$/@`
and
`},)<>'"<{\@..(_$.>.$;`
[Answer]
## PHP, ~~82~~ ~~29~~ ~~24~~ ~~29~~ 28 characters
```
<?=strrev(fread(STDIN,2e9));
```
82 -> 29: The new line character is preserved when reversed with `strrev`.  
29 -> 24: Uses the shortcut syntax now  
24 -> 29: Now reads all lines instead of a single line
[Answer]
## Befunge-98 - ~~11~~ 10
```
#v~
:<,_@#
```
(Tested with cfunge)
The variant below breaks the requirement slightly: it performs the task but outputs an infinite stream of null bytes afterwards (and doesn't terminate).
```
~#,
```
The way it works is that it repeatedly reads input to the stack (`~`) one character at a time, jumping over (`#`) the comma. When EOF is reached, `~` acts as a reflector and the PC flips over, repeatedly popping and outputting a character (`,`) while jumping over (`#`) the tilde.
[Answer]
# Pyth - 3 ~~5~~ 4 bytes
So, the original 3-char version didn't reverse the line order, just the lines. I then came up with this 5-char version:
```
_jb.z
```
I saved 1 byte thanks to @FryAmTheEggman to result it:
```
_j.z
```
[Live demo.](https://pyth.herokuapp.com/?code=_j.z&input=Quick+brown+fox%0AHe+jumped+over+the+lazy+dog&debug=1)
## Explanation:
```
  .w  read all the input into a list of strings
 j    join (j) by using a newline character
_     reverse the result
      Pyth implicitly prints the result on an expression
```
# Original (incorrect) solution:
This technically doesn't count because Pyth was created in 2014, but it's still neat that it's tied with GolfScript.
```
#_w
```
## Explanation:
```
#    loop while no errors
  w  read a line of input (throws an error on end-of-file or Control-C)
 _   reverse the input line
     Pyth implicitly prints the result on an expression
```
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix/), ~~9~~ 8 bytes
Many thanks to Martin Ender for this golf:
```
w;o@i.?\
```
[**See it work online!**](http://ethproductions.github.io/cubix/?code=dztvQGkuP1w=&input=T09QIDop&speed=1)
This becomes the following cube (`>` indicates initial instruction pointer):
```
      w ;
      o @
> i . ? \ . . . .
  . . . . . . . .
      . .
      . .
```
The first step of the program is to take all input. `i` puts 1 byte of input onto the stack. Unless the input is finished, `?` makes the IP turn right, wrapping around the cube until it reaches `w`, which sends it back to `i`.
When input finishes, the `?` makes the IP head north, entering the output loop:
* `o`: print the character at the top of the stack
* `w`: 'sidestep' the pointer to the right
* `;`: pop the character that was just printed
* `\`: reflect the IP, sending it East
* `?`: if there are chars left to print, turn right, back into the loop.
The final time `?` is hit, when nothing is left on the stack, the IP continues forward instead:
* `i`: take a byte of input. This will be `-1` as input has finished.
* `\`: reflect the IP, sending it North, into:
* `@`: terminate the program.
---
# 9 byte solution
```
..o;i?@!/
```
[**See it work online!**](http://ethproductions.github.io/cubix/?code=Li5vO2k/QCEv&input=T09QIDop&speed=20)
In cube form:
```
      . .
      o ;
> i ? @ ! / . . .
  . . . . . . . .
      . .
      . .
```
The first character encoutered is `i`, which takes a charcode of input. If there is no input left, this is `-1`.
The next character is `?` - a decision. If the top of stack is positive, it turns right, wrapping around the cube until it hits `/` which sends it back to the `i`, creating an input loop. However, if the TOS is negative, input has finished, and so it turns left into the output loop.
The output loop is simple. `o;` outputs and pops the TOS. The first time this is run, `-1` is the top of stack, but does not map to a character and is therefore ignored. `/` reflects the IP to move left, where it encounters `!@` - which terminates the program if the stack is empty. Otherwise, the IP continues, hitting `?` again - because the stack is not empty, the TOS must be a charcode, all of which are positive1, so this makes the IP turn right and continue the output loop.
---
*1 Both solutions assume that the input will not contain null bytes.*
[Answer]
## [Wumpus](https://github.com/m-ender/wumpus), 12 bytes
```
i=)!4*0.l&o@
```
[Try it online!](https://tio.run/##Ky/NLSgt/v8/01ZT0UTLQC9HLd/h///A0szkbIWkovzyPIW0/Aouj1SFLKDC1BSF/LLUIoWSjFSFnMSqSoWU/HQA "Wumpus – Try It Online")
---
[Martin's answer](https://codegolf.stackexchange.com/a/155862/21487) showcases Wumpus' triangular grid control flow well, but I thought I'd give this challenge a try with a one-liner.
The easier to understand version (one byte longer) is:
```
i=)!8*0.;l&o@
```
which works like so:
```
[Input loop]
i        Read a byte of input (gives -1 on EOF)
=)!      Duplicate, increment then logical not (i.e. push 1 if EOF, else 0)
8*       Multiply by 8 (= x)
0        Push 0 (= y)
.        Jump to (x, y), i.e. (8, 0) if EOF else (0, 0) to continue input loop 
[Output]
;        Pop the extraneous -1 at the top from EOF
l&o      Output <length of stack> times
@        Terminate the program
```
Now let's take a look at the golfed version, which differs in the middle:
```
i=)!4*0.l&o@
```
The golfed version saves a byte by not needing an explicit command `;` to pop the extraneous -1. On EOF, this program jumps to `(4, 0)` instead of `(8, 0)` where it executes `4*0.` again — except this time the extraneous -1 is on top! This causes us to jump to `(-4, 0)`, which due to wrapping is the same as `(8, 0)` for this grid, getting us where we want whilst consuming the extraneous value at the same time.
[Answer]
## [Wumpus](https://github.com/m-ender/wumpus), ~~13~~ 11 bytes
```
)?\;l&o@
=i
```
[Try it online!](https://tio.run/##Ky/NLSgt/v9f0z7GOkct34HLNvP//8DSzORshaSi/PI8hbT8Ci6PVIUsoLrUFIX8stQihZKMVIWcxKpKhZT8dAA "Wumpus – Try It Online")
### Explanation
Since Wumpus is a stack-based language, the basic idea is to read all STDIN to the stack and then just print the entire stack from top to bottom. The interesting part here is the control flow through the grid.
To understand the control flow, we need to look at the actual triangular grid layout:
[![enter image description here](https://i.stack.imgur.com/H9yh1.png)](https://i.stack.imgur.com/H9yh1.png)
The IP starts in the top left corner going east. We can see that there's a loop through the group of six cells on the left, and a branch off of the `\`. As you might expect, the loop reads all input, and the linear section at the end writes the result back to STDOUT.
Let's look at the loop first. It makes more sense to think of the first `)?\` as not being part of the loop, with the actual loop beginning at the `i`. So here's the initial bit:
```
)   Increment an implicit zero to get a 1.
?\  Pop the 1 (which is truthy) and execute the \, which reflects the IP
    to move southwest.
```
Then the loop starts:
```
i   Read one byte from STDIN and push it to the stack (or -1 at EOF).
    Note that Wumpus's grid doesn't wrap around, instead the IP reflects
    off the bottom edge.
=   Duplicate the byte we've read, so that we can use it for the condition
    later without losing it.
)   Increment. EOF becomes zero (falsy) and everything else positive (truthy).
?\  If the incremented value is non-zero, execute the \ again, which 
    continues the loop. Otherwise (at EOF), the \ is skipped and the
    IP keeps moving east.
```
That leaves the linear section at the end:
```
;   Get rid of the -1 we read at EOF.
l   Push the stack depth, i.e. the number of bytes we've read.
&o  Print that many bytes.
```
[Answer]
# [Wren](https://github.com/munificent/wren), ~~40~~ 33 bytes
After I discovered a really clever trick...
```
Fn.new{|a|System.write(a[-1..0])}
```
[Try it online!](https://tio.run/##Ky9KzftfllikkKhg@98tTy8vtby6JrEmuLK4JDVXr7wosyRVIzFa11BPzyBWs/Z/ol5yYk6OhpKhkbGJkuZ/AA)
## [Wren](https://github.com/munificent/wren), 53 bytes
Wren has no STDIN functions... I guess I will just be using a function instead of hard-coding the value and using a snippet (which is a bit risky).
```
Fn.new{|a|[-1..-a.count].each{|w|System.print(a[w])}}
```
[TIO](https://tio.run/##Ky9KzftfllikkFaal6xg@98tTy8vtby6JrEmWtdQT083US85vzSvJFYvNTE5o7qmvCa4srgkNVevoCgzr0QjMbo8VrO29j9Is15yYk6OhpJnXkFpiZLmfwA)
## Explanation
```
Fn.new{                                               Create a new anonymous function (because Wren has no input functions)
       |a|                                            With the parameter a
          [-1..-a.count]                              Generate the range [-1,-2,...,len(a-1),len(a)]
                        .each                         Pass this range to the given function:
                             {|w|                     Take one parameter a
                                 System.print(a[w])}} And output it to STDOUT
```
## Wren, 54 bytes
```
Fn.new{|a|
for(i in-1..-a.count)System.write(a[i])
}
```
[TIO](https://tio.run/##Ky9KzftfllikkFaal6xg@98tTy8vtby6JrGGKy2/SCNTITNP11BPTzdRLzm/NK9EM7iyuCQ1V6@8KLMkVSMxOjNWk6v2P0ivXnJiTo6GkmdeQWmJkuZ/AA)
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 31 bytes
```
a:-get0(C),C>0,a,put(C);!.
:-a.
```
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/P9FKNz21xEDDWVPH2c5AJ1GnoLQEyLFW1OOy0k3U@/8/sDQzOVshqSi/PE8hLb@CyyNVIas0tyA1RSG/LLVIoSQjVSEnsapSISU/HQA "Prolog (SWI) – Try It Online")
[Answer]
## PHP - 44 characters
```
<?=strrev(file_get_contents('php://stdin'));
```
]