Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You implemented the problem wrong, and thus got an error. If hats is a list of colors, then every hat != green is true if the list is empty.


I wouldn’t say it is wrong per se. It certainly defies the conventional translation into FOL, but there is no a priori reason to pick the conventional formalism of FOL for this problem.


I don't think that's true. What if the liar buys a red hat?

    liar.hats.push("red")
This only works if hats is an empty array. If hats is just not a property people have (undefined in the example), then you can't represent adding them.

Now you might argue hats can be null when a user doesn't have them, or a non-empty array, but that's clearly not a great way to represent that. Now you have owning no hats represented two different ways as an empty array or null, and must build special casing around the null case (unless you are using a language where nil and the empty array are one and the same)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: