This message was deleted.
# show-and-tell
s
This message was deleted.
m
Like I mentioned in the other thread, I can't share my solutions directly, but this is my day 4 part 2 function, and I think that might be interesting:
Copy code
function part2(input) {
  const counts = Object.fromEntries(input.map(card => [card.id, 1]));
  for (let card of input) {
    let wins = new Set(card.winningNumbers);
    let matchCount = card.playNumbers.filter(p => wins.has(p)).length;
    for (let i = 0; i < matchCount; i++) {
      let key = card.id + i + 1;
      if (Object.hasOwn(counts, key)) {
        counts[key] += counts[card.id];
      }
    }
  }
  return d3.sum(Object.values(counts));
}
input
is pre-parsed from my puzzle input, and is an array of objects. I think the rest is pretty apparent, but happy to share more or explain more