r/dailyprogrammer • u/nottoobadguy • Feb 21 '12
[2/21/2012] Challenge #13 [intermediate]
Create a program that will take any string and write it out to a text file, reversed.
input: "hello!"
output: "!olleh"
13
Upvotes
2
u/geraudster Feb 22 '12
BrainFuck, using standard output:
Explanation :
2
u/this_space Feb 23 '12
php
1
u/_redka 0 0 Feb 21 '12
Ruby
1
u/electric_machinery Feb 21 '12 edited Feb 21 '12
bash
edit: direct to file > $2
usage:
$ reverse.sh Hello! file.txt
$ cat file.txt
!olleh
1
u/Koldof 0 0 Feb 21 '12
Isn't that pretty, but it works well enough.
1
u/drb226 0 0 Feb 21 '12
Haskell:
Usage:
1
u/cooper6581 Feb 21 '12
Trivial solution in C
1
u/[deleted] Feb 22 '12
This took me so long to do, it almost drove me completely insane. Did it in C++.
1
u/robin-gvx 0 2 Feb 22 '12
No file I/O yet in Déjà Vu, but if stdout counts as a file, we get this one-liner:
1
u/RyGuyinCA Feb 22 '12
I did it in C++ and tried to use STL to do the work for me.
1
u/lukz 2 0 Feb 22 '12
Common Lisp
Using standard output.
1
u/luxgladius 0 0 Feb 22 '12 edited Feb 22 '12
Perl
usage: perl rev.pl out.txt whatever you want here.
1
u/Vectorious Jun 07 '12 edited Sep 18 '25
salt divide crown pause rain glorious cough rinse repeat office
This post was mass deleted and anonymized with Redact
0
u/southof40 Feb 22 '12
Python:
-1
u/kirk_o Feb 22 '12 edited Feb 22 '12
C++
0
u/[deleted] Feb 21 '12
[deleted] — view deleted comment