Skip to content

Instantly share code, notes, and snippets.

@Toshimo-Kamiya
Created December 2, 2023 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Toshimo-Kamiya/c4c64fa4cea477bded97a14524e75ff6 to your computer and use it in GitHub Desktop.
Save Toshimo-Kamiya/c4c64fa4cea477bded97a14524e75ff6 to your computer and use it in GitHub Desktop.
$total = 0
Get-Content C:\Users\tmahone\Desktop\payload.txt | % {
$red = [int](($_ | select-string -pattern '(\d+) red' -AllMatches).Matches.Groups | ? { $_.Name -eq "1"} | Sort @{Expression = {[int]$_.Value}} | Select -Last 1).Value
$green = [int](($_ | select-string -pattern '(\d+) green' -AllMatches).Matches.Groups | ? { $_.Name -eq "1"} | Sort @{Expression = {[int]$_.Value}} | Select -Last 1).Value
$blue = [int](($_ | select-string -pattern '(\d+) blue' -AllMatches).Matches.Groups | ? { $_.Name -eq "1"} | Sort @{Expression = {[int]$_.Value}} | Select -Last 1).Value
$total = $total + $red * $green * $blue
}
$total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment