Most of today was spent in meetings with the PHB*, explaining why our project is behind schedule.
A quick virtual summary (what I imagine was said, rather than what was actually said): So anyway, it was a relief to get back to programming. As I dug into a bitmap edge detection algorithm, I ran into a spot where I needed to check the eight pixels surrounding the current one, in clockwise order, given any starting position. I whipped out a quick conditional statement that tested for each of eight possibilities, which works fine, but is ugly. Since it worked ok, I couldn't justify a lot of time to optimize it, so I gave myself five minutes to see if I could come up with a slicker way to do it. I didn't, so I moved on, but now it's 11PM and I just thought of another way to do it, and I figured it might be fun to see if anyone can find an even simpler solution.
So here's the problem ...
Consider the following diagram:
Find a single function f(x,y) that, given any one set of the eight coordinates, returns the coordinates of the adjacent square, moving clockwise. You may use any mathematical operands, including rounding, absolute value, trig functions, etc., but no conditionals.
*Pointy Haired Boss
No comments:
Post a Comment