Skip to content

Commit

Permalink
#33: Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jaccomoc committed Dec 28, 2023
1 parent 013dc53 commit 683bede
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/_posts/2023-12-02-advent-of-code-2023-day2.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ For the games that could have occurred we sum their ids and that is the solution

```groovy
def bag = [red:12, green:13, blue:14]
stream(nextLine).map{ /Game (\d+): (.*)$/n
stream(nextLine).map{
/Game (\d+): (.*)$/n
[$1, $2.split(/;/)
.flatMap{ it.split(/,/).map{ /(\d+) (.*)/n; [$2,$1] }}
.allMatch{ colour,count -> count <= bag[colour] }] }
.filter{ it[1] }.map{ it[0] }.sum()
.flatMap{ it.split(/,/)
.map{ /(\d+) (.*)/n; [$2,$1] }}.allMatch{ colour,count -> count <= bag[colour] }]
}.filter{ it[1] }.map{ it[0] }.sum()
```

The solution was pretty straightforward.
Expand Down

0 comments on commit 683bede

Please sign in to comment.