Morendil comments on Quixey Engineering Screening Questions - Less Wrong

2 Post author: Liron 09 October 2010 10:33AM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (22)

You are viewing a single comment's thread. Show more comments above.

Comment author: Morendil 09 October 2010 05:25:11PM 0 points [-]

Tee-hee. There are many ways to skin these cats. :)

(What puzzles me is why the formulation of the problem fails to ban the absolutely trivial solution that uses neither type of loop. Wondering if that's intentional or a brain fart.)

Comment author: Liron 09 October 2010 06:31:08PM 0 points [-]

If you're thinking of writing n lines of code with calls to alert(), it doesn't work because you have to submit a constant-sized program before you see n. Otherwise please email me this trivial solution because I may have overlooked it.

Comment author: Morendil 09 October 2010 07:33:26PM 0 points [-]

Actually the brainfart was on my part. I'd forgotten that a common instruction doesn't exist in Javascript, though that hasn't kept some folks from implementing one, as a workaround. (The mind boggles.)

You'll need to specify which version of Javascript to target, since some slightly less obvious solutions may involve version-dependent features.

Comment author: Liron 09 October 2010 07:36:23PM 0 points [-]

My current solution is 12 lines long and uses only recursion and function calls and addition and variable assignments.