OSDN Git Service

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