Skip to content

Instantly share code, notes, and snippets.

@sorah

sorah/webgame.js Secret

Created September 4, 2011 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorah/99a643bdbcb978b0fada to your computer and use it in GitHub Desktop.
Save sorah/99a643bdbcb978b0fada to your computer and use it in GitHub Desktop.
Google Developer Day 2011 Tokyo / DevQuiz: Web Game
a = $(".card").map(function(i,v){
return $(v).click().css("background-color")
})
r = []
$(a).each(function(i,v){
var ans = undefined;
var flag = true;
$(a).each(function(j,b){
if(v == b && j != i ){
ans = j;
}
});
$(r).each(function(j,b){
if(b[0] == ans && b[1] == i) {
flag = false
}
});
if(ans && flag) {
r.push([i,ans])
}
});
$(r).each(function(i,v){
$("#card"+v[0]).click();
$("#card"+v[1]).click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment