Adventures with Python - I
10 Apr 2015I just had an awesome adventure coding with Python for a programming task which involved converting a base32 string to a base64 one. Below is the code:
import base64
t = int(raw_input())
for i in range(0, t):
str = raw_input()
sol = base64.b64encode(base64.b32decode(str))
print sol
Brilliant, isn’t it? I mean even to think of a code this awesome requires hours and hours of dedication!
Being a Rubyist, I always marvelled at how Ruby makes writing programs simpler and intuitive. But after this small venture into Python programming I have realised two things:
- Ruby lacks lusture when it comes to programming apart from Rails. :’(
- Python is extremely powerful and elegant looking.
(I mean I really miss writing the end
keyword here.)
A few months back I was of the opinion that Ruby is totally self-sufficient when it comes to Scientific, Image Processing and Cryptographic applications. But yeah, it is definitely not so. Python has proven to be super powerful in a lot of domains and has very well maintained libraries.
Interestingly, I have reached all these conclusions from a code which converts one string into another. I am not completely taking (my beloved) Ruby out of the equation but trying to flirt around with Python for some different action altogether.
Until the next adventure!
P.S: This emotional blog post has also to do with the fact that I could not code up the solution in Ruby.