Created
December 10, 2023 03:22
-
-
Save errorseven/77ecbe635671891a298fb5717bd07319 to your computer and use it in GitHub Desktop.
Advent of Code 2023 - Day 4: Scratchcards
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
; 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