A background and good understanding of programming helps too. I had a friend who graduated in 3 years w/ a 3.6 and a 4.0 in CS going to 1/5th of all his classes. Programs that took other people all week and about 25-30 hours he'd do in a 1 night 5 hour session. This kid was smart as hell though. I'd ask him how to do something and he'd scribble all sorts of things on a piece of paper that no one could read or figure out and then he'd create something out of it that worked.
Oh yeah, this story is great. In DiffEq class he went the first day, left HALFWAy through the FIRST day of class never to go to class again. The first test he didn't know who the prof was and I had to point him out. Anyways, he ended up teaching all of us DiffEq at the end of the semester and ended up w/ a B+ while all of us who actually went to class pulled B-'s and C+'s...being smart helps..