Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts
10.18.2009
Found my old PONG program
In preparation for my MIT application, which is due in less than two weeks, I was snooping around some old files (like 7th grade old, on my 10GB hard drive from that era). I completed my objective: I rediscovered a word document containing a transcribed version of the PONG clone I wrote back then. It's shorter than I remembered (about 55 lines), but somehow also uglier. So I cleaned it up a little and rearranged some of it so it doesn't redraw the screen three times. Now it's 10 lines shorter. It's very simple, but I remember it as my first foray into the world of code. It's hard for me to believe that 7th grade was only five years ago. Anyway, here's the cleaned-up version in a text file (because I don't have a transfer cable or any of that fancy stuff). Enjoy it. I'm not entirely sure whether you can license TI-BASIC code, but whatever portion of that output is legally mine you can reproduce and change so long as you release the result with the same conditions.
Labels:
games,
math,
open source,
programming,
school
12.18.2008
New (small) factoring library
So, this is the result of repeated use of several factoring-oriented functions for project euler. It's quite small, and any semi-competent programmer could probably come up with a faster or more efficient solution, but these were mine and they work perfectly well for my purposes. Everything is pretty straightforward, I figured the docstring was enough documentation and it isn't commented, but use it if you want. Everything I write, unless it says otherwise (which it won't unless it's for a job or for someone else to sell) is released under the GPL, despite my general perception that no one will ever want to reproduce it. In any event, the library is here.
I'm particularly happy with the primefactor function. It's my first successful (and actually useful) attempt at recursion, and it works very well. As the docstring suggests, the getprimes function (which is utilized by primefactor) slows down around n = 100000 or so, but I've optimized it the best I can, and I think it's fine for most practical applications. Anyway, enjoy.
I'm particularly happy with the primefactor function. It's my first successful (and actually useful) attempt at recursion, and it works very well. As the docstring suggests, the getprimes function (which is utilized by primefactor) slows down around n = 100000 or so, but I've optimized it the best I can, and I think it's fine for most practical applications. Anyway, enjoy.
7.12.2008
Project Euler
I recently discovered an awesome site, projecteuler.net, which has 202 mathematically-based programming tests. This is really helpful to someone like me who's learning a language and needs some practice, but doesn't have to program for his or her job. You can download my solution to problem three, in python, (preferably after you've solved it yourself) at tauntaun.10gbfreehost.com/code/problem3.zip
If you know of any other similar sites that supply programming challenges, I'd love to hear about them in the comments. Unfortunately, I have a sneaking suspicion that no one but me will ever see this post.
I've also tried the quizzes at pythonchallenge.org, but those seem to move at a much faster rate and, well, I'm a little slow.
If you know of any other similar sites that supply programming challenges, I'd love to hear about them in the comments. Unfortunately, I have a sneaking suspicion that no one but me will ever see this post.
I've also tried the quizzes at pythonchallenge.org, but those seem to move at a much faster rate and, well, I'm a little slow.
Subscribe to:
Comments (Atom)