Showing posts with label SPOJ. Show all posts
Showing posts with label SPOJ. Show all posts

Wednesday, August 18, 2010

Update Ruby

I went through ruby tutorial due to some reasons and it turned out that using Ruby smaller codes can be written for challenge problems in spoj like KAMIL and SIZECON.

Results :

In problem KAMIL from size of 71 in python i jumped to 43 in Ruby.
Similarly, problem SIZECON reduced from 48 in python to 44 in Ruby.

Tuesday, August 17, 2010

SUCCESS

This is a tutorial problem in spoj. Link to the problem SUCCESS
The best i could manage is 26 in C. It includes printing "Success" as a returned value from brb() function. If you want to print "Success" as such then my best was 31. Here's the source code:

main(){exit(!puts("Success"));}

If anyone has better solution please share :)

Sunday, August 15, 2010

KAMIL

This is a challenge task in spoj. Link to the problem KAMIL
The best i could manage is 71 in python. Here's the source code:


for i in range(10):
b=1
for i in raw_input():
if i in'LFTD':b*=2
print b


If anyone has better solution please share :)

PS : Here i am attaching the code with score of 77 because i think that its size can be reduced. If you want the 71 char. code then reply back.

SIZECON

This is a challenge task in spoj. Link to the problem SIZECON
The best i could manage is 48 in python. Here's the source code:


q=0
w=input()
while w:
w-=1
a=input()
if a>0:q+=a
print q

if anyone has done better please share your approach :)