Trying my hand at this competitive programming thing again. Google Code Jam is this weekend again, so what is there for a rookie to lose? Even better, no rounds overlap with my birthday!
My high-level approach was the following: I'll look one problem at a time, and I'll do it then and there if I can come up with a solution in 10s. If not, I'll revisit it. I like this approach better than looking at all of the problems first since I can have just one thing on my mind at any time.
The first problem is essentially pattern matching. You're given a 4x4 board and you want to see if any rows, columns, and major/minor diagonal matches some string. I was feeling lazy, so I hardcoded the patterns and did a brute force search. Not too bad.
I couldn't think of a brain-dead solution for the second problem, so I skipped it for now.
The third problem required finding palindromes that are squares of palindromes. Given that this is in a programming contest, of course there will be some cleverness involved. I then looked at the input sizes. There were not just two, but THREE (a first!) inputs, the first one with a bound of 1000 (trivial), the next with a bound of 10^14 (decent, I can just do it with 64-bit integers, or so I thought), and the third had a bound of 10^100 (excuse me?). I first pooped some code for the small case, which happily ran in time. I then realized that I can adapt this for the large case, but was unconfident about constant factors, which may or may not destroy me.
I decided to port the code to C++ to play it safe, or so I thought. "Clearly C++ is much faster than Python, so that should save me, right?" said naïve me. I coded it up, generated some random input data, tested the code using that, and found that it ran in time. "Sweet." I then downloaded the large-1 test case, computed the results, and uploaded my answers.
I wasn't too sure what to do for the largest test case. I thought computing the palindromic palindrome-squares indefinitely was a good idea to figure out a general pattern, since I noticed only ~1% of numbers less than 1000 satisfied the condition and some very small fraction of numbers less than 10^14 satisfied the condition. From the ongoing run, I noticed that there were some more numbers less than 10^14 that my C++ program failed to find. "This is weird," I thought. After a while, I noticed that one of my helper functions took an int instead of an uint64_t. I changed it, reran my code, and verified that I found my error: one of my function arguments was an int, instead of an unsigned long long. Good game.
I couldn't think of any way to solve the 10^100 case, so I moved onto the next problem.
The fourth problem at first looked like a search problem. Upon glancing at the input sizes, I figured there had to be some dynamic programming involved. I was feeling pretty tired at this point, so I shut my laptop and fell asleep.
Since the contest happened during a subset of MIT's Campus Preview Weekend (which I happily attended three years ago; more on this year's CPW in another post), I didn't work on Code Jam until about T-30min. I felt somewhat annoyed about not having solved problem 2, since all of my other friends solved it (bad logic, I know). Apparently I understood the concept of the solution, from talking afterwards to a person who solved it, but I struggled to put 1 and 1 together to make 2. Thus, I pooped something that would solve the [overconstrained] small test at T-8min, which happily passed.
The qualification round ended soon enough. As expected, I got all but my problem 3 large right. Not bad, for being a few years out of practice.
13 April 2013
28 March 2013
Breaking the vim addiction
alias vim='open -a Sublime\ Text\ 2.app'
Labels:
technology
17 March 2013
Pointless
What's the point of ponying up roughly $150k - 200k to go to a school such as MIT, just to get a job that pays only $100k/yr without much room to expand -- say $250k/yr max? It seems like the same could be accomplished by going to a state school on a full scholarship and saving the money for a nice car.
Labels:
life
03 March 2013
Working in the Terminal
A couple years ago, I read an article about relying more on the terminal as a way to decrease distractions, thereby increasing efficiency. I finally took this guy's word and spent the past week moving my email and messaging routines to mutt and irssi-xmpp respectively. The programs are running in screen on a server.
In addition to being a command line hipster (ha :P), I can save a small chunk of RAM from not having Gmail as an open tab in Webkit. This is especially helpful for running Lightroom, which enjoys gobbling system memory. Sure, this workflow has limitations (attaching files to emails, for example), but it's a small move that I hope will ultimately wean me off my attachment to electronic communications.
In addition to being a command line hipster (ha :P), I can save a small chunk of RAM from not having Gmail as an open tab in Webkit. This is especially helpful for running Lightroom, which enjoys gobbling system memory. Sure, this workflow has limitations (attaching files to emails, for example), but it's a small move that I hope will ultimately wean me off my attachment to electronic communications.
Labels:
technology
14 February 2013
06 February 2013
KawaiiKart: Mechanical Assembly DONE!
Alright. This is the third-to-last post that ends the KawaiiKart saga! I am extremely naive, at least considering my current trajectory. Actually the aforementioned claim seems fine, since all I have left is getting the EV section to run, then the gas engine to run, and finally coordinating the two!! I will detail the assembly of most of the kart, from most of the steering assembly to mounting the engine.
At first I waterjetted on quality 4 (second best), but the waterjet's software said that it would take an hour as well as 50lb of abrasive. I decided to let it run for a while, but I realized that my routing did not include small tabs on the parts (to prevent the parts from falling into the waterjet tub), which the second part did. At this point, I stopped the waterjet, added tabs to my parts, and reran at quality 3. The run time and abrasive consumption were much more reasonable, clocking in at 14 minutes total and 7 lb of sand.
The new knuckles turned out to be perfect. At this point, I was supposed to have a rolling frame, but by virtue of sloppiness, I forgot to order 3/8"-24 nuts, some steering column lock collars, as well as more L joints for the tie-rod steering.
Up next: electronics and a working EV!
MLK weekend
Remember from last time that I messed up the steering knuckles? I got a chance to re-waterjet my parts (on campus! no week-long delays!) with a nice Omax waterjet. Unfortunately, there were no 0.25" thick aluminum sheets that were large enough, so I was going to make twice the number of parts on a 0.125" thick sheet.
It's a $400,000 printer that takes sheets of aluminum!
At first I waterjetted on quality 4 (second best), but the waterjet's software said that it would take an hour as well as 50lb of abrasive. I decided to let it run for a while, but I realized that my routing did not include small tabs on the parts (to prevent the parts from falling into the waterjet tub), which the second part did. At this point, I stopped the waterjet, added tabs to my parts, and reran at quality 3. The run time and abrasive consumption were much more reasonable, clocking in at 14 minutes total and 7 lb of sand.
The new knuckles turned out to be perfect. At this point, I was supposed to have a rolling frame, but by virtue of sloppiness, I forgot to order 3/8"-24 nuts, some steering column lock collars, as well as more L joints for the tie-rod steering.
Better waterjetted steering knuckle: the nut fits!! (of course I winged it)
Vise-ing bearings into steering mounts.
The legendary T-nut.
Assembled frame!
My temporary parking space at MITERS.
Charlesg welded my unidirectional flywheel tight.
Testing the fit of the wheel axles.
Taking a break to track ChibiKart in the snow. This is the result.
Mounting the steering knuckles.
An engine and wheels appeared!
Servicing engine mount with a makeshift carjack.
Week before Techfair
This is the week when the EVERYTHING happens. Literally. It's the last week of my externship, Battlecode quals + finalists' dinner + final tournament, and KawaiiKart cram week. Basically all the time after work was dedicated to either writing code for Battlecode or working on the go-kart. During this week, I went from chassis and parts to a mostly working kart. Picture dump below:
Scraping self against a piece of aluminum or Nancy's hexapod.
Using vise as holder to insert one notch into motor mount.
Vising entire motor mount into steering knuckle.
Chibi motors!
Mounting motors onto motor mount.
The bore of the pinion gear is slightly too large, so we'll pad it with Coke can.
Too lazy to file deeper notch in motor shaft.
Adjusting pinion gear on motor shaft.
Motor on wheel!
I fail at ordering parts again.
It's a masterlink!
Cutting fluid does wonders.
The chain is on! Now to tighten it a bit more.
Steering column with tie rods!
The MITERS parking garage.
Side profile.
My hands turn black after a day's worth of hard work.
BigLathe!
Motor controller (it's a Kelly controller).
Revised steering column end mount.
That steering wheel was not intended for this vehicle.
Soldering the Hall sensors onto those boards was really annoying!!!
Last but not least
The correct way to listen to K-pop is to turn the bass all the way up, and then knock the treble down a few notches to compensate.
Up next: electronics and a working EV!
Labels:
kawaiikart,
MITERS
12 January 2013
KawaiiKart: December/Early IAP Update
I spent most of yesterday night working on KawaiiKart. In fact, I promised myself not to leave MITERS until the rear wheel was on the chassis. This is more complicated than it sounds because I screwed up assembling the rear of the kart twice!
My first problem was that the distance between the aluminum extrusions was too wide. Turns out you must take into every little dimension when CADding parts. Since I normally work with things that have infinite tolerance (code/math)...go figure -_- The solution wasn't too tricky; I made two plates that went on top of the extrusions that connected two more extrusions on the respective insides.
The second issue dealt with how my rear wheel was installed. Since I had the wheel essentially slide into the space between the aluminum extrusions, I couldn't tighten the bolts if I first installed the extrusions onto the chassis.
That's all for now! Hopefully I can have a rolling frame (with motors!!) by the end of MLK.
My first problem was that the distance between the aluminum extrusions was too wide. Turns out you must take into every little dimension when CADding parts. Since I normally work with things that have infinite tolerance (code/math)...go figure -_- The solution wasn't too tricky; I made two plates that went on top of the extrusions that connected two more extrusions on the respective insides.
This solution introduces more torsional flex, but to what extent is unknown so far. It seems to pass a rudimentary twist and sit test, though.
The second issue dealt with how my rear wheel was installed. Since I had the wheel essentially slide into the space between the aluminum extrusions, I couldn't tighten the bolts if I first installed the extrusions onto the chassis.
Here's to hoping I tightened the bolts enough such that the wheel won't fall off during operation!
I also had a slew of smaller issues, like incorrectly measuring dimensions and not accounting for dimensions and the like.
Because the axle diameter isn't 5/8"; it's really 10mm!
Because T-nuts have finite size
Because axles have finite length and need to be secured...somehow.
That's all for now! Hopefully I can have a rolling frame (with motors!!) by the end of MLK.
Labels:
kawaiikart
01 January 2013
Happy 2013! / 2012 in Review
Happy New Year! I don't think I've made many nontechnical posts recently so here's a treat for everyone.
First up: New Years Resolutions (not in any particular order).
Working out Recreational powerlifting three (or more) times a week worked quite well, even during hectic first term junior year. I don't know how I did it (maybe by throwing a class under a bus), but it worked quite well. I'm convinced it's one of the very few things that kept me sane this term. I really only did curls, sometimes bench presses and squats, but never deadlifts because I dislike doing them. I'm well aware that MIT has a powerlifting team, but I don't think I'll be joining them anytime soon due to lack of time.
First up: New Years Resolutions (not in any particular order).
- No more computer purchases unless they will be arbitraged.
- Focus -- learn to say no.
and lastly, finish your scooter!
Next, year in review. 2012 was one of the better years. I'm bummed that I didn't pull off any noteworthy hacks, but this year is looking good with KawaiiKart. I however did manage to sneak in a cool project, my GPU ray tracer. Sadly it doesn't yet use all four GPUs or photon map or <insert cool effect or optimization here>.
The coolest thing I did was actually in the way beginning of the year: I briefly drove a Porsche 911 Carrera GTS! It was quite an experience, from the euphoric engine roar to getting behind the wheel and driving it. I look forward to signing the lease in 2018...or 2019 if necessary.
Bayley and I managed to hit a practical wall in our arms race by going to quad socket platforms near the end of the year. (pictures will be coming soon -- these things are epic!) We're still waiting for various sales on Newegg and parts on Ebay, so they'll be done sometime before junior year ends.
In any event, happy new year!
Labels:
life
19 December 2012
KawaiiKart Chassis Assembled!
Or part of. If I fail my finals, this would be the reason.
It only took about three hours to cut the 80/20 into their requisite lengths (while screwing up the lengths for the main chassis because I don't know how to use a ruler -__-) and screw them together. Hopefully I get more done after finals.
Labels:
kawaiikart
10 December 2012
The Nicest Balls You Will Ever See
Labels:
gpgpu,
ray tracing
Subscribe to:
Posts (Atom)










































