See: https://adventofcode.com/2020/day/2 ** Part 1 *** Purpose Given a list of passwords and their supposed requirements #+begin_example 1-3 a: abcde 1-3 b: cdefg 2-9 c: ccccccccc #+end_example Return the amount of valid passwords. Password one requires 1-3 'a' characters. Password 2 is invalid. *** Method Simply parse each input and store them in... Well, let's do a list: #+begin_example (passwd char (min max)) #+end_example Then, create a function count occurances of CHAR in PASSWD, and see how it compares to RANGE. ** Part 2 *** Purpose The password verification method has changed: #+begin_example 1-3 a: abcde 1-3 b: cdefg 2-9 c: ccccccccc #+end_example Now, the "range" corresponds to two indices (indexed from 1). Of these indices, exactly one needs to be the given CHAR. *** Method See implementation. Simply, we add a wrapper to the valid-password? function that refines the inputs before calling valid-password? as usual.