Live data from Hacker News

Return True to Win

alf.nu

71–80 of 123 posts

Re: Return True to Win

#72

For the first 5, I've got 2,3,8,14,7. Anybody got tighter solutions?

The counter one (level 4) can be done with 11 chars. Solution below, found on Reddit[1]. Also, I could not manage fewer than 9 characters for level 3. (Edit: thanks @ensard)

Spoiler here: x=>_=>x=-~x

And also in this link: [1]: https://www.reddit.com/r/programming/comments/4wd32v/return_...

Re: Return True to Win

#74
post #4

The game shows us how ugly JS is.

Indeed, I refuse to believe there should be a solution to the 'reflexive' task.

That one isn't specific to Javascript, though. If you can find a mainstream language that doesn't have any values that aren't equal to themselves, I'll give you a cookie.

(Going from memory of the last time I tried this challenge, since I can't get it to load at the moment.)

Re: Return True to Win

#77

Does anybody really know why JS's type system was designed the way it was? It seems so out of whack with what people want out of a language, dynamically typed or otherwise.

It's because Eich was told to make JS C-like. In C, an empty array, an empty string, 0, false and null are all the same value: a word with all bits 0. So in JS, those are all are falsy and == to each other.
Post reply on HN