Hacker News new | ask | show | jobs
by hueving 4114 days ago
How do you eliminate stuff that is slow just for the sake of being slow? For example, a find_in_list function that iterates through the list N! times to 'protect against cosmic rays' or something along those lines.
1 comments

By requiring to terminate and return a result?
Of course. Just test to see if the program terminates or not.
While halting problem can't be solved, you can solve the problem by saying all programs must terminate within 20min and program must scale with input length.

And/Or you can forbid sleep and similar nop functions.

And/Or you can sit down and analyze the code.

Truth be told, it makes for a very boring competition, but a very useful exercise.