Created
June 14, 2025 10:09
-
-
Save Fuzzyma/bf3a80c76cf9bef40aafa0fe107bafaf 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 = Number(a.classList[2].split("-")[1]) % 90 === 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