Created
June 13, 2025 07:52
-
-
Save Fuzzyma/57734f60b493e6071bdf40b9789706f5 to your computer and use it in GitHub Desktop.
Paste this into the browser console of https://devrel.wearedevelopers.com/code100-puzzles/041-hearts-and-minds/hearts-and-minds.html to see the result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const all = [...document.querySelectorAll("#canvas div")]; | |
const map = {}; | |
// I could use 4 filters but I rather loop once | |
all.forEach((a) => { | |
const isBrain = a.textContent === "🧠"; | |
const isStraight = a.classList.contains("rot-0"); | |
const isLeft = Number(a.classList[0].split("-")[1]) < 50; | |
const key = `${isBrain}${isStraight}${isLeft}`; | |
map[key] = (map[key] ?? 0) + 1; | |
}); | |
console.log({ | |
straightBrains: map["truetruetrue"] + map["truetruefalse"], | |
leftBrains: map["truetruetrue"] + map["truefalsetrue"], | |
straightHearts: map["falsetruetrue"] + map["falsetruefalse"], | |
rightHearts: map["falsetruefalse"] + map["falsefalsefalse"], | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment