blob: 15d87ab1d625ac806cac1a663979968f1156ed48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
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.
|