Skip to content

Instantly share code, notes, and snippets.

@marclundgren
Last active December 29, 2015 03:39
Show Gist options
  • Save marclundgren/7609130 to your computer and use it in GitHub Desktop.
Save marclundgren/7609130 to your computer and use it in GitHub Desktop.
3 gods, true, false, random
/*
Three gods A, B, and C are called, in no particular order, True, False, and Random.
True always speaks truly, False always speaks falsely, but whether Random speaks truly or falsely is a completely random matter.
The gods understand English, but will answer all questions in their own language, in which the words for yes and no are da and ja, in some order. You do not know which word means which.
*/
(function() {
function randomBool () {
return !! Math.round(Math.random() * 1);
}
var GODS = {
TRUE: true,
FALSE: false,
RANDOM: randomBool()
};
/* Determines the identities of A, B, and C by asking three yes-no questions
each question must be put to exactly one god
*/
function determineWhoisWHo() {
/* The gods understand English,
but will answer all questions in their own language,
in which the words for yes and no are da and ja, in some order.
(You do not know which word means which...)
*/
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment