NEXTODD2 - Next odd extreme golf

Given an integer 1 <= N <= 10000, you have to print the next odd number.

Just one restriction you have to equal or better my best 14 bytes solution.

http://www.spoj.com/ranks/NEXTODD/

Score = source code length

Input

The input file consists of series of numbers one in each line. The input is terminated by EOF.

Output

The next odd number followed by a new line.

Example

Input:
5
2
6
17 Output: 7
3
7
19

Added by:Aditya Pande
Date:2013-01-17
Time limit:1s
Source limit:14B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Golfing

hide comments
2013-01-19 18:51:59 Alex Anderson
Being in classical doesn't mean "The problem isn't trivial." Imo, the focus is on the algorithm, not on minimizing code length. If SHORTEN problems were considered classical, there wouldn't be a SHORTEN contest on spoj in the first place. However, this doesn't mean I'm against lowering the source code limit, because for some problems you can hardcode the answers which is sometimes not intended.

Besides that, I'll also say that I don't think it shouldn't be in Challenge either, because apparently if you know what to do, it isn't a challenge. Challenge problems should have lots of solutions, but it should be very hard to get the very best solution. Plus, it is nice that there is no guarantee that you actually have the best if your best is 125B or something like that.

EDIT: It literally took me 30minutes to look up AWK and figure out how to solve in 10 characters. Before this, I didn't even know what AWK was.

EDIT:( ADITYA ): I respect your point of view but my 14 bytes solution does not rely as heavily as yours on the knowledge of the language. Apparently the problem is more focused on the knowledge of AWK rather than a good way to do it. I respect your opinion and move this to tutorial \

However, I disagree to the statement that only 10 byte solution can pass. No 10 bytes is perhaps the best way but there are many other ways of doing it though each needs some knowledge of AWK....

Last edit: 2013-01-19 18:57:07
2013-01-19 18:51:59 Ehor Nechiporenko
For 14 bytes all problems except AWK could be removed.
And my AWK solution contains only 10 characters.
-->Congrats, nice idea in your implementation. My 14bytes code just needed to delete 4 characters without any other change as such...

Last edit: 2013-01-18 19:16:13
2013-01-19 18:51:59 Mohamed Maher
should be moved to challenge
-->no many people will be able to get 3points that way and it is not advisable...imho

Last edit: 2013-01-18 07:47:40
2013-01-19 18:51:59 SAHIL SAREEN
no possible solution in C/C++.. :C
--->each language has its own characteristics and advantages. Therefore one should select a language carefully. Please look forward to solving other problems.

Last edit: 2013-01-17 19:08:33
2013-01-19 18:51:59 (Tjandra Satria Gunawan)(曾毅昆)
I think this problem is very good for Brainf**k, could you set it?
---> Imho it is easy for BF. I can set such a problem if you want it though....:)
On a completely different note, why can't i use html tags? :(
Edit: Yes, I know... But you can make it harder, e.g high constraints, more rules :-D
About html code tags, I don't know how, I can use it since I become problem setter (activated by admin), maybe..

Last edit: 2013-01-18 02:19:54
2013-01-19 18:51:59 Mitch Schwartz
I'd say it's trivial if you know AWK reasonably well.
---> it obviously requires in depth knowledge of the language and also a decent experience in golfing. i'd still therefore say it is non trivial..

I still disagree, but ok I'll take the free points.
--->try http://www.spoj.com/problems/OVOXO/. It should give you some sort of effort i hope....:)

Last edit: 2013-01-17 19:04:39
2013-01-19 18:51:59 Mitch Schwartz
The best has been 10 for a long time http://www.spoj.com/SHORTEN/ranks/NEXTODD/

Besides, with this scoring it counts as challenge even though it is in classical section, that's how SPOJ works at the moment.

It's in tutorial section here and on SHORTEN for a reason...

>ANS:->i did not know that the same problem was on SHORTEN and had been solved in 10 bytes by 7 people...
imho it can still be a classical problem with the given code size limit...the problem is not trivial with the given constraints
however if you want it then i can hide the problem or send it to tutorial.

Last edit: 2013-01-17 16:51:25
2013-01-19 18:51:59 Alex Anderson
I'd prefer if this were in Challenge.
>ANS:-> i would move it there later..if you wish so....

Last edit: 2013-01-17 15:19:32
2013-01-19 18:51:59 Aditya Pande
congrats XeRoN!X you are the first to solve this problem.
Edit( XeRoN!X ) : :D

Last edit: 2013-01-17 18:59:25
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.