Hacker News new | past | comments | ask | show | jobs | submit login

I'm sure this will be added to their set of test cases :)



Corner cases are hard. Here's a little C program; try to figure out what it prints before you compile & run it. It computes a step size between two numbers, given a number of steps:

#include <stdio.h>

int f(unsigned n_steps, int from_val, int to_val){ int step_size = (from_val - to_val) / n_steps; return step_size; }

int main(){ printf("f(3, 0, 30) = %d\n", f(3, 0, 30) ); printf("f(3, 30, 0) = %d\n", f(3, 30, 0) ); }


> Corner cases are hard.

Yeah, they are, but your example is not good enough, it is like an example from a textbook on traps of C.

Corner cases hard when you are trying to do something new, because if you did it before, you'd know the most of them. Or if someone else did it before and wrote a textbook. =)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: