Created
January 18, 2021 15:59
-
-
Save mjgpy3/1a430ecf8eed831f4cc677b985b571c3 to your computer and use it in GitHub Desktop.
aoc-2020-d2.tab
This file contains 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
regex = '([0-9]+)-([0-9]+) ([a-z]): ([a-z]+)', | |
sum([ | |
parts = grep(@, regex), | |
ct = count(grep(parts[3], parts[2])), | |
uint(parts[0]) <= ct && ct <= uint(parts[1]) | |
: @ | |
]) |
This file contains 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
regex = '([0-9]+)-([0-9]+) ([a-z]): ([a-z]+)', | |
sum([ | |
parts = grep(@, regex), | |
bs = bytes(parts[3]), | |
b = bytes(parts[2])[0], | |
(b == bs[uint(parts[0])-1]) ^ (b == bs[uint(parts[1])-1]) | |
: @ | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment