Skip to content

Instantly share code, notes, and snippets.

@mjgpy3
Created January 18, 2021 15:59
Show Gist options
  • Save mjgpy3/1a430ecf8eed831f4cc677b985b571c3 to your computer and use it in GitHub Desktop.
Save mjgpy3/1a430ecf8eed831f4cc677b985b571c3 to your computer and use it in GitHub Desktop.
aoc-2020-d2.tab
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])
: @
])
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