Learning to program, again

I haven’t written a program since Pascal was in it’s heyday. I learned to program in FORTRAN, then picked up assembly language for a couple of different DEC mini-computers, and finally became fluent in Pascal. Notably, C is not a language I have used, nor is Unix/Linux an OS I’m really familiar with.

Learning a new programming language on a new OS is not something I can do in snatches of time. I’ve tried, and become terribly frustrated. So, I’ve been devoting concentrated effort on learning Python (2.7.2) on OSX (at the terminal obviously, no fancy GUI stuff yet). I started with figuring out how to read stuff from a file, do something with it, and print some things. That introduced me to strings, lists, iterators, and files. Somewhere during looking stuff up on the web I ran across a reference to Project Euler, a programming challenge website.

Then I found Python-coded solutions to the first 50 problems, so using that as my crib sheet, I started writing my own solutions to these problems. This has been a steep learning curve for a couple of reasons. First, lots of Python constructs look like greek to me, and it takes me quite a while to figure out what they do and how I can apply them. Second, some of the problems require math concepts that I may have once known about back in college, but having never used them, I’m now learning them again.

Python is very interesting and powerful. It generally doesn’t take very many lines of code to do some very useful stuff. For instance, one of the problems was to find the left-most 10 digits of the sum of one-hundred 50-digit numbers. Since Python has long (really long…) integers, the program is almost trivial.

    big_numbers =(int(x) for x in data.problemx.strip().splitlines())  
    return int(str(sum(big_numbers))[:10])
I don’t yet think like a Python programmer. My programs are longer (more lines) than the examples I’m following, but sometimes run faster. I think my old programming experience is still causing me to think about the size of data structures and keeping them to a minimum.

I’ve completed 15 of the problems, but they are getting harder, so I may stop and see if I can get some simple cipher tools developed.

1 comment to Learning to program, again

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>