OSDN Git Service

Update docs.
[joypy/Thun.git] / docs / Advent_of_Code_2017_December_4th.md
1
2 # Advent of Code 2017
3
4 ## December 4th
5 To ensure security, a valid passphrase must contain no duplicate words.
6
7 For example:
8
9 * aa bb cc dd ee is valid.
10 * aa bb cc dd aa is not valid - the word aa appears more than once.
11 * aa bb cc dd aaa is valid - aa and aaa count as different words.
12
13 The system's full passphrase list is available as your puzzle input. How many passphrases are valid?
14
15
16 ```python
17 from notebook_preamble import J, V, define
18 ```
19
20 I'll assume the input is a Joy sequence of sequences of integers.
21
22     [[5 1 9 5]
23      [7 5 4 3]
24      [2 4 6 8]]
25
26 So, obviously, the initial form will be a `step` function:
27
28     AoC2017.4 == 0 swap [F +] step
29
30
31     F == [size] [unique size] cleave =
32
33
34 The `step_zero` combinator includes the `0 swap` that would normally open one of these definitions:
35
36
37 ```python
38 J('[step_zero] help')
39 ```
40
41     0 roll> step
42     
43
44
45     AoC2017.4 == [F +] step_zero
46
47
48 ```python
49 define('AoC2017.4 == [[size] [unique size] cleave = +] step_zero')
50 ```
51
52
53 ```python
54 J('''
55
56 [[5 1 9 5]
57  [7 5 4 3]
58  [2 4 6 8]] AoC2017.4
59
60 ''')
61 ```
62
63     2
64