Skip to content

Instantly share code, notes, and snippets.

@errorseven
Created December 10, 2023 03:22
Show Gist options
  • Save errorseven/77ecbe635671891a298fb5717bd07319 to your computer and use it in GitHub Desktop.
Save errorseven/77ecbe635671891a298fb5717bd07319 to your computer and use it in GitHub Desktop.
Advent of Code 2023 - Day 4: Scratchcards
; Copy Problem Data to Clipboard before you Run
data := StrSplit(trim(clipboard), "`r", "`n")
results := 0
for each, line in data {
winningCard := {}, x := 0
line := StrSplit(StrReplace(line, " ", " "), ": ").2
cards := StrSplit(line, " | ")
for e, v in StrSplit(Trim(cards.1), " ")
winningCard[v] := 1
for k, v in StrSplit(Trim(cards.2), " ") {
if (winningCard.HasKey(v))
x := (x >= 1 ? (x * 2) : 1)
}
results += x
}
msgbox % clipboard := results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment