My experience with Python and C so far


I started Python on 18th May 2013 after I discovered that doing project euler problems via C(my primary language) wasn’t easy for me. Using Python doing those problems were quite easy. I started neglecting C and went ahead with Python with zeal. That has been helpful as using Python I have been able to solve 59 problems on project euler so far.

My project Euler progress so far.

Using C I went ahead to solving problems 11 and then felt discouraged. Maybe I wasn’t focusing on the logic so much.

By Python I have been able to do some things that I couldn’t do using C. Like making solutions easily to some problems. Using scripting in Python I found out that looking into files, copying them and many other things can be extremely easy.

  • I wrote scripts for finding whether I had done a particular thing in C but not in Python and vice versa. I arranged the files in folders for using this script but organizing code is always nice.  What was taking me a lot of time manually now can be done by a simple double-click now.
  • Writing a lot of functions in a single file was starting to be confusing. I wrote up a script for finding the function signatures. Took out a lot of confusion.
  • Check my github repo if you want to have a look at any of these scripts/

I am thinking about breaking down the file containing all the functions into many different files. That is the only way to go forward if I want to keep writing. Then I am thinking of making a GUI that I can use to separate all the functions by tags. I don’t know much how to do that as of now but I think I’ll use wxPython but that isn’t final.

I found that there are always a lot of new things that can be learned in programming and that stackoverflow can be a great resource. Check out my list of favourite questions and my own questions on stackoverflow. Maybe you’ll find something that you are looking for.

I have found out that using online judging can be a great thing. I have been using codechef for practicing C and Python. By using this I discovered that I will need to learn many algorithms and that there a lot more things to learn in any programming language that I choose to learn. It has been really helpful and the community is good. I started reading other people’s code thanks to codechef and stackoverflow. It has been helpful to me. I discovered that I can discover many different ways of doing things by looking at other people’s code. I initially joined github for the the same reason – looking at other people’s code. But I discovered that looking at other people’s code also helps if there is a large vvariety of code and their time and memory usage is available.

I  tried spoj for 2-3 days. I think there are more problems for practice than on codechef but I will need to learn more algorithms before I seriously try to solve them.

Solving codechef’s problems I discovered that the simple program of factorial that I usually wrote in C wouldn’t work even for factorials of 100. I later found out a way to calculate factorials of any number. It will be needing some polishing and final touches but I found a way.

I have placed Python on hold for past few days. I use it now and then but I am shifting focus back on C. I have started the MIT’s course Introduction to algorithms whose I have placed with a lot of other programming links. It is nice. I have finally overcome my fear of sorting algorithms. They are kind-of-basic things in programming but I couldn’t do them properly. While using linked lists, stacks etc. was something that I could do sorting was difficult for me. But now I am able to write insertion sort, selection sort, bubble sort and merge sort easily. Reading Cormen’s Book of algorithm is a challenge that I have taken up. It is more than 1300 pages book so it is a huge challenge but I believe that it can bridge a lot of gaps in my knowledge.

Using codereview is helpful. It helped me in changing a lot of formatting problems and bad coding practices that I was using. I have decided to get code reviewed for all algorithms that I use. Writing review is helpful. Looking up someone’s code and trying to give suggestions is good as experience.

I have some things to do this week. I’ll try to do programming in spare time. I’ll keep my focus on C and learning algorithms. I believe it would be helpful in the long run.