REVINPUT - Reverse the Input

A simple task is a rare thing in SPOJ these days. If you are looking for one, then this is just the task for you! All you need to do is to reverse the input N times.

Score is the length of your solution.


The first lines of the input is an integer N (1 <= N <= 100). Next follows the input consisting of ASCII characters. The input is terminated by EOF. You may assume that length of each word is less then 1024 and maximum number of words can be never more than 1024.


The input reversed N times with atleast a space/newline between any two words of your output.



fox jumps over the lazy dog.


.god .god yzal yzal eht eht revo revo spmuj spmuj xof xof



It matters not how strait the gate,

How charged with punishments the scroll.

I am the master of my fate:

I am the captain of my soul.


.luos ym fo niatpac eht ma I 

:etaf ym fo retsam  eht ma I 
.llorcs eht stnemhsinup htiw degrahc woH 
,etag eht tiarts woh ton srettam tI 

.luos ym fo niatpac eht ma I 

:etaf ym fo retsam  eht ma I 

.llorcs eht stnemhsinup htiw degrahc woH 

,etag eht tiarts woh ton srettam tI 


Added by::(){ :|: & };:
Time limit:1s
Source limit:1000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: SCM qobi

hide comments
2014-05-09 09:16:04 785227
My code is showing WA, please check my submission ID 11544282
2013-11-23 23:27:54 Mitch Schwartz
According to my tests, the input is pretty well behaved: the space character and "\n" are the only whitespace characters that occur; two whitespace characters in a row do not occur; and the only strange thing is that the last line is never terminated with "\n", and sometimes there is a trailing space and sometimes there isn't.

Last edit: 2013-11-24 02:37:53
2011-09-29 10:11:14 Hallvard Norheim Bø
Which characters are considered as whitespace here?
Can there be more than one whitespace character between each word?
2011-03-07 23:24:19 Piotr KÄ…kol
I can see the effect. ;-)
2011-03-07 18:37:28 :(){ :|: & };:

well, in that link I have the option but it has no effect after execution.
2011-03-05 22:46:48 Piotr KÄ…kol
Even here? :-O
2011-03-05 22:30:32 :(){ :|: & };:
@Piotr: No it seems like as I don't have any jurisdiction in this contest so I can't disqualify anything here.

ALL is available now.

Last edit: 2011-03-05 22:32:20
2011-03-04 12:53:46 Piotr KÄ…kol
Do You mean I should disqualify it?
Is so, can't You do it?
It would be weird because I can disqualify submissions in my tasks.

PS Could You add CLOJ, F# etc.?
2011-03-04 10:42:22 :(){ :|: & };:

I was just trying to tweak with the best solution ... Poitr if disqualify my submission.
2010-09-01 13:25:33 :(){ :|: & };:

Perl 6 is added.
© All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.