-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yml
31 lines (27 loc) · 1.24 KB
/
main.yml
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
---
- name: Loop over every character for 4 characters
tags: part1
ansible.builtin.set_fact:
packet_pos: "{{ item + 1 }}"
vars:
prev_4: "{{ [day6_input[item - 3], day6_input[item - 2], day6_input[item - 1], day6_input[item]] }}"
when: packet_pos is not defined and prev_4 | unique | length == 4
loop: "{{ range(3, day6_input | trim | length) | list }}"
- name: ANSWER TO PART 1 | Return the position of the packet
tags: part1
ansible.builtin.debug:
msg: "{{ packet_pos }}"
- name: Loop over every character for 14 characters
tags: part2
ansible.builtin.set_fact:
msg_pos: "{{ item + 1 }}"
vars:
# not gonna bother making this prettier tbh
prev_14: "{{ [day6_input[item - 13], day6_input[item - 12], day6_input[item - 11], day6_input[item - 10], day6_input[item - 9], day6_input[item - 8], day6_input[item - 7], day6_input[item - 6], day6_input[item - 5], day6_input[item - 4], day6_input[item - 3], day6_input[item - 2], day6_input[item - 1], day6_input[item]] }}"
when: msg_pos is not defined and prev_14 | unique | length == 14
loop: "{{ range(3, day6_input | trim | length) | list }}"
- name: ANSWER TO PART 2 | Return the position of the message
tags: part2
ansible.builtin.debug:
msg: "{{ msg_pos }}"
...