Hacker News new | ask | show | jobs
by ttul 1716 days ago
Haha. Reminds me of a lab where we had to program a 6502 to play some sort of game, rendered on an oscilloscope. My genius friend stayed up all night writing code that rendered the snake by dynamically writing code, rather than the obvious approach of reading the “snake” coordinates and rendering those to the screen.

Our snake code ran at something obscene like 1,000 Hz. So much faster than anyone else’s. The professor couldn’t understand how we did it, so gave a low mark.

3 comments

>The professor couldn’t understand how we did it, so gave a low mark.

That was genuinely upsetting to read.

In High School 2004 I made a license plate detection system for our IT class project. It was not perfect, granted, but was able to locate license plates in a photograph pretty reliably and do OCR on them.

Teacher was like, nah, that's not possible, and clearly hadn't even read it. Gave me an A just to stop me complaining, still not understanding the project.

My Fortran professor gave me a low mark because I used a lookup table for octal to binary conversion, instead of using division and modulo.
In a teaching lab in 1995, I had to make a digital thermometer using a mcu. I wrote code that dynamically read the voltage drop on the sensor and calculated the temperature. It was fast enough and easy to calibrate. The code was small and easy to understand.

I didn’t pass because the point of the assignment was to use lookup tables, even though that was a more complex approach in this case :(

"It was fast enough and easy to calibrate."

Are you sure about easy to calibrate 8) Did your solution have the same level of accuracy across the range as the MCU would provide?

Bizarrely, you sometimes have to follow the standards because that is what everyone does. I can't think of an example now but there will and have been cases in engineering where the wrong answer is the right one because that is what is done. I know of mensuration devices that "model" some curves with a linear approximation and paper over the errors with cough error estimates and/or keeping within the nearly linear range. That too is fine if everyone understands what is going on.

Accuracy is a funny old thing.

However, I like your approach and it shows you probably understand the principles involved. Ideally, if you are going to be a smart arse like that, then submit two solutions - the proscribed one and your clever one.

You mention a MCU but not what sort of sensor ...

Curious as to what you mean by "dynamically writing code"
Like meta programming, creating a string to define a query and then executing the string. In the case above, you dynamically create the program you need to solve the problem and then execute it. This is different than "solving the problem". You are writing a program to "write the program to solve the problem".
Doesn't sound like this kind of complicated string eval would be able to do 1000Hz but then again I also have no clue where you could possibly need that for a snake game. On an oscilloscope you'd need to produce vector lines to move from/to right?
More likely, I would wager that they were just overwriting the instructions to draw with new instructions that just inline everything so it didn't need to fetch out to anything.
Yes. This.