4 ms·
I certainly can't get it to work. For the first problem, I tried: function one_bit(x) { return x & (x-1) == 0 } Only to see this error: Expected "}
by fourspace 13y ago
I certainly can't get it to work. For the first problem, I tried:
function one_bit(x) {
return x & (x-1) == 0
}
Only to see this error:
Expected "}" or comment but "&" found.
WAT
- dalke 13y agoIt appears to have a limited JS validator to prevent you from using anything other than the limited operators it allows.
- sp332 13y agoIt really doesn't like having anything after "return" except a single value or variable.
- dalke 13y agoThat's not it. For example, it accepts "return x|x&x;" . The restriction is that only a handful of Javascript operations are allowed. Anything else gives a hard-to-understand error message.
- wellingtons 13y agoYou can't use '-'.
- warmfuzzykitten 13y agoThat returns true or false, which I believe strictly speaking aren't numeric in Javascript. By definition of problem, probably should be: function one_bit(x) { return x & (x-1) == 0 ? 1 : 0; }