Wednesday, December 1, 2010

Challenge Problems SPOJ

KAMIL
for i in range(10):t=raw_input();print 2**sum(t.count(i)for i in'DFLT')

10.times{q=1 gets.gsub(/[DTFL]/){q*=2} p q}

1st one : python
2nd one : ruby


POLYBIUS
for i in range(input()):
for j in raw_input():
j=ord(j)
if j>73:j-=1
if j>64:print 2*j-j%5-119,

Language python

SUCCESS
main(){brk(printf("%m"));}

Language C

SIZECON
s=0;gets.to_i.times{b=gets.to_i;s+=b if b>0}
p s

Language ruby

Saturday, October 16, 2010

Spamming

#!/usr/bin/python
import smtplib

sender = 'admin@zzz.ac.in'
receivers = ['xxx@gmail.com']
# sender = in mail transcript it will show this sender address
# receivers = actual address where we want to send the mail

message = """From: name 
To: name 
Subject: Test Mail, plz ignore

how are you ?

"""

smtpObj = smtplib.SMTP('students.iiit.ac.in')
# do change smtpObj according to your position
print "Successfully sent email"
smtpObj.sendmail(sender, receivers, message)



When this python code is run, it will send the mail to the addresses mentioned in receivers which is a list in python. prototype is similar to gmail. It does show the ip address in the complete info of the mail. But there's a way to hide ip in proxy servers. Try it.

About the Blog

I may be a little late in writing this post but still it has to be clarified as what this blog refers to. Here i am going to point to the things which i think are worth sharing and some of them are going to be completely random.

Monday, September 13, 2010

SPOJing Ends

I think i have done enough questions in spoj and time has come to practice somewhere else, some place where there are more people to compete with. Even though in spoj i couldnt go beyond 335, but that's enough to say that i am no more a rookie :)

PS : My spoj handle -> arpit_s

Sunday, August 29, 2010

UBUNTU vs VISTA

You may be wondering, why has he written VISTA, on what basis is he comparing these tw0. You are right, because if we consider certain points :

1. Ubuntu OS is based on the Linux distribution and is available for free, i.e., it is open source. :D where as Vista is Microsoft product.
2. Both are entirely different, whatever be the aspect, GUI, deadlock management, etc..
3. Vista has been succeeded by Windows 7 where as ubuntu still holds its place.
comparing them is not justified, but since i am blogging i have right to post whatever i want :) .

Vista has been labelled as a complete failure by my friends and knowns. But my experience has been completely different with Vista. I never had problem with it, it never crashed. Where as ubuntu on the other hand, keeps on coming with some problem every other day. Sometimes firefox crashes, sometimes problem with pdf opener(evince). It gets stuck and then you had to force quit through it, even that option fails sometimes.

Friday, August 20, 2010

IIIT Hyderabad

Being a self-financed deemed university, IIIT Hyderabad provides a wide contrast to other institutes throughout India. Our curriculum, administration and procedural activities are quite different. Growth of IIIT is really amazing, only after 12 years of its opening, it is there in the top ten technology institutes of the country.

After giving AIEEE 2008 i too heard the name of this institute for the first time. The thing that benefited me was that my brother himself has cleared AIEEE in 2005 and was doing Btech from NIT Trichy during my counselling period. He discussed with his friends about various institutes that could be filled as an option. Since i wasn't sure of getting my first choice i had to consider other options as well. What i have observed is that, after 12th class noone is oriented to any particular trade, unless until he has been involved into any such kind of thing before. I had a bit of idea about it, because of my brother. He suggested IIIT Hyderabad and NIT Trichy as the final choice for the ccb counselling choices. I got myself enrolled in Computer Science Dual degree programme which involved two degree(BTech + MS).

The curriculum changed from the batch of 2k8, i.e., on the year i got into iiit. This is not the first time that something has changed when i have put my steps onto it. From the year 2k8, state quota was removed from AIEEE, but fortunately with good AIR i managed to get seat in IIIT. In IIIT, there is a committee or group to look after every other issue. Such things you dont often observe in Engineering institutes. I thought that administration is going to be slack in such issues, they would consider just the study aspect, but i was wrong, they want the people related to the institute to be organised, so that we will be responsible towards others as well. We were not subjected to the courses like Chemistry, Mechanics or Engineering Drawing etc., which the student of other institutes studies in first year, it includes iitians as well. Flexibility that curriculum provides is great, but some of the faculty members suffer from Jeevan Vidya.

I dont know how they could ask students to do things which are ideal in nature, may be when we will come to their age we will understand the importance of it too.

PS : Views can differ from people to people. I have written what i think of IIIT-H.

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 :)