|
|
|
|
|
by S4M
4053 days ago
|
|
I haven't interviewed for quite a while, but I might do so pretty soon. What surprises me in this blog post is not the question itself - I find it quite reasonable - but the pickiness of the interviewer. If I was asked this, I suppose that I would come up with some kind of bruteforce, like writing a function to combine two numbers and an operator (the empty string can be an operator): function combine(x,operator,y) {
if(operator === "+") {
return x+y;
}
if(operator === "-") {
return x-y;
}
if(operator === "") {
return 10*x+y;
}
return 0;
}
And then getting the 3^8 possible combinations of 8 operators linking the number together and picking the ones that give 100 as the final result.While I am sure this solution is not completely efficient, I would expect it to show that I can write Javascript. Would that get me rejected for the job? |
|