Skip to content

Instantly share code, notes, and snippets.

@jorendorff
Created November 14, 2018 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorendorff/56637ec4da868206ccc689b845fb65f6 to your computer and use it in GitHub Desktop.
Save jorendorff/56637ec4da868206ccc689b845fb65f6 to your computer and use it in GitHub Desktop.
var total = 0;
var points = 0; // points so far in the current round
var draw = 0; // how many cubes you've drawn so far in the current round
var round = 1;
while (round < 20000) {
print("round", round);
points = 0;
//while (draw < 2) { // 2-draw strategy
//while (points < 5) { // Abby's strategy
//while (points < 2) { // chicken 2 strategy
//while (points < 10) { // turkey 10 strategy
while (points < 47543) { // goblin strategy
var cube = Math.floor(Math.random() * 3); // random 0, 1, or 2
if (cube == 0) { // yellow
print("yellow");
points = 0;
break;
}
if (cube == 1) { // red
print("red");
points = points + 1;
draw = draw + 1;
}
if (cube == 2) { // blue
print("blue");
points = points + 4;
draw = draw + 1;
}
print(points, "points so far...");
}
total = total + points;
// end of round
print();
round = round + 1;
draw = 0;
}
print("done!");
print("total score:", total);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment