advent_of_ruby 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/arb +1 -1
- data/data/solutions/reddit/ruby/2015/02.yml +5 -5
- data/data/solutions/reddit/ruby/2015/03.yml +6 -6
- data/data/solutions/reddit/ruby/2015/04.yml +7 -7
- data/data/solutions/reddit/ruby/2015/05.yml +6 -6
- data/data/solutions/reddit/ruby/2015/06.yml +14 -14
- data/data/solutions/reddit/ruby/2015/07.yml +15 -15
- data/data/solutions/reddit/ruby/2015/08.yml +6 -6
- data/data/solutions/reddit/ruby/2015/09.yml +11 -11
- data/data/solutions/reddit/ruby/2015/10.yml +18 -18
- data/data/solutions/reddit/ruby/2015/11.yml +19 -19
- data/data/solutions/reddit/ruby/2015/12.yml +10 -10
- data/data/solutions/reddit/ruby/2015/13.yml +9 -9
- data/data/solutions/reddit/ruby/2015/14.yml +11 -11
- data/data/solutions/reddit/ruby/2015/15.yml +9 -9
- data/data/solutions/reddit/ruby/2015/16.yml +7 -7
- data/data/solutions/reddit/ruby/2015/17.yml +10 -10
- data/data/solutions/reddit/ruby/2015/18.yml +4 -4
- data/data/solutions/reddit/ruby/2015/19.yml +1 -1
- data/data/solutions/reddit/ruby/2015/20.yml +2 -2
- data/data/solutions/reddit/ruby/2015/21.yml +4 -4
- data/data/solutions/reddit/ruby/2015/22.yml +5 -5
- data/data/solutions/reddit/ruby/2015/23.yml +3 -3
- data/data/solutions/reddit/ruby/2015/24.yml +11 -11
- data/data/solutions/reddit/ruby/2015/25.yml +5 -5
- data/data/solutions/reddit/ruby/2016/01.yml +5 -5
- data/data/solutions/reddit/ruby/2016/02.yml +3 -3
- data/data/solutions/reddit/ruby/2016/03.yml +1 -1
- data/data/solutions/reddit/ruby/2016/04.yml +4 -4
- data/data/solutions/reddit/ruby/2016/05.yml +3 -3
- data/data/solutions/reddit/ruby/2016/06.yml +4 -4
- data/data/solutions/reddit/ruby/2016/07.yml +3 -3
- data/data/solutions/reddit/ruby/2016/08.yml +6 -6
- data/data/solutions/reddit/ruby/2016/09.yml +1 -1
- data/data/solutions/reddit/ruby/2016/10.yml +3 -3
- data/data/solutions/reddit/ruby/2016/11.yml +1 -1
- data/data/solutions/reddit/ruby/2016/12.yml +3 -3
- data/data/solutions/reddit/ruby/2016/14.yml +4 -4
- data/data/solutions/reddit/ruby/2016/15.yml +11 -11
- data/data/solutions/reddit/ruby/2016/16.yml +1 -1
- data/data/solutions/reddit/ruby/2016/17.yml +3 -3
- data/data/solutions/reddit/ruby/2016/18.yml +3 -3
- data/data/solutions/reddit/ruby/2016/20.yml +2 -2
- data/data/solutions/reddit/ruby/2016/21.yml +7 -7
- data/data/solutions/reddit/ruby/2016/22.yml +10 -10
- data/data/solutions/reddit/ruby/2017/01.yml +7 -7
- data/data/solutions/reddit/ruby/2017/02.yml +15 -15
- data/data/solutions/reddit/ruby/2017/03.yml +9 -9
- data/data/solutions/reddit/ruby/2017/04.yml +4 -4
- data/data/solutions/reddit/ruby/2017/05.yml +12 -12
- data/data/solutions/reddit/ruby/2017/06.yml +16 -16
- data/data/solutions/reddit/ruby/2017/07.yml +5 -5
- data/data/solutions/reddit/ruby/2017/08.yml +18 -18
- data/data/solutions/reddit/ruby/2017/09.yml +7 -7
- data/data/solutions/reddit/ruby/2017/10.yml +9 -9
- data/data/solutions/reddit/ruby/2017/11.yml +1 -1
- data/data/solutions/reddit/ruby/2017/12.yml +6 -6
- data/data/solutions/reddit/ruby/2017/13.yml +6 -6
- data/data/solutions/reddit/ruby/2017/14.yml +1 -1
- data/data/solutions/reddit/ruby/2017/15.yml +3 -3
- data/data/solutions/reddit/ruby/2017/16.yml +5 -5
- data/data/solutions/reddit/ruby/2017/17.yml +6 -6
- data/data/solutions/reddit/ruby/2017/18.yml +7 -7
- data/data/solutions/reddit/ruby/2017/19.yml +2 -2
- data/data/solutions/reddit/ruby/2017/20.yml +5 -5
- data/data/solutions/reddit/ruby/2017/21.yml +11 -11
- data/data/solutions/reddit/ruby/2017/22.yml +1 -1
- data/data/solutions/reddit/ruby/2017/23.yml +1 -1
- data/data/solutions/reddit/ruby/2017/25.yml +3 -3
- data/data/solutions/reddit/ruby/2018/01.yml +20 -20
- data/data/solutions/reddit/ruby/2018/02.yml +16 -16
- data/data/solutions/reddit/ruby/2018/03.yml +12 -12
- data/data/solutions/reddit/ruby/2018/04.yml +6 -6
- data/data/solutions/reddit/ruby/2018/05.yml +15 -15
- data/data/solutions/reddit/ruby/2018/06.yml +4 -4
- data/data/solutions/reddit/ruby/2018/07.yml +11 -11
- data/data/solutions/reddit/ruby/2018/08.yml +9 -9
- data/data/solutions/reddit/ruby/2018/09.yml +13 -13
- data/data/solutions/reddit/ruby/2018/10.yml +10 -10
- data/data/solutions/reddit/ruby/2018/11.yml +9 -9
- data/data/solutions/reddit/ruby/2018/12.yml +2 -2
- data/data/solutions/reddit/ruby/2018/13.yml +14 -14
- data/data/solutions/reddit/ruby/2018/14.yml +5 -5
- data/data/solutions/reddit/ruby/2018/15.yml +2 -2
- data/data/solutions/reddit/ruby/2018/16.yml +7 -7
- data/data/solutions/reddit/ruby/2018/17.yml +1 -1
- data/data/solutions/reddit/ruby/2018/18.yml +6 -6
- data/data/solutions/reddit/ruby/2018/19.yml +1 -1
- data/data/solutions/reddit/ruby/2018/20.yml +1 -1
- data/data/solutions/reddit/ruby/2018/21.yml +4 -4
- data/data/solutions/reddit/ruby/2018/22.yml +3 -3
- data/data/solutions/reddit/ruby/2018/23.yml +11 -11
- data/data/solutions/reddit/ruby/2018/24.yml +4 -4
- data/data/solutions/reddit/ruby/2018/25.yml +6 -6
- data/data/solutions/reddit/ruby/2019/01.yml +11 -11
- data/data/solutions/reddit/ruby/2019/02.yml +13 -13
- data/data/solutions/reddit/ruby/2019/03.yml +7 -7
- data/data/solutions/reddit/ruby/2019/04.yml +11 -11
- data/data/solutions/reddit/ruby/2019/05.yml +10 -10
- data/data/solutions/reddit/ruby/2019/06.yml +7 -7
- data/data/solutions/reddit/ruby/2019/07.yml +8 -8
- data/data/solutions/reddit/ruby/2019/08.yml +8 -8
- data/data/solutions/reddit/ruby/2019/09.yml +4 -4
- data/data/solutions/reddit/ruby/2019/10.yml +4 -4
- data/data/solutions/reddit/ruby/2019/11.yml +7 -7
- data/data/solutions/reddit/ruby/2019/12.yml +17 -17
- data/data/solutions/reddit/ruby/2019/13.yml +6 -6
- data/data/solutions/reddit/ruby/2019/14.yml +2 -2
- data/data/solutions/reddit/ruby/2019/15.yml +3 -3
- data/data/solutions/reddit/ruby/2019/16.yml +6 -6
- data/data/solutions/reddit/ruby/2019/17.yml +3 -3
- data/data/solutions/reddit/ruby/2019/18.yml +1 -1
- data/data/solutions/reddit/ruby/2019/20.yml +9 -9
- data/data/solutions/reddit/ruby/2019/21.yml +3 -3
- data/data/solutions/reddit/ruby/2019/22.yml +3 -3
- data/data/solutions/reddit/ruby/2019/23.yml +1 -1
- data/data/solutions/reddit/ruby/2019/25.yml +2 -2
- data/data/solutions/reddit/ruby/2020/01.yml +30 -30
- data/data/solutions/reddit/ruby/2020/02.yml +25 -25
- data/data/solutions/reddit/ruby/2020/03.yml +17 -17
- data/data/solutions/reddit/ruby/2020/04.yml +26 -26
- data/data/solutions/reddit/ruby/2020/05.yml +35 -35
- data/data/solutions/reddit/ruby/2020/06.yml +40 -40
- data/data/solutions/reddit/ruby/2020/07.yml +16 -16
- data/data/solutions/reddit/ruby/2020/08.yml +13 -13
- data/data/solutions/reddit/ruby/2020/09.yml +21 -21
- data/data/solutions/reddit/ruby/2020/10.yml +29 -29
- data/data/solutions/reddit/ruby/2020/11.yml +8 -8
- data/data/solutions/reddit/ruby/2020/12.yml +22 -22
- data/data/solutions/reddit/ruby/2020/13.yml +15 -15
- data/data/solutions/reddit/ruby/2020/14.yml +11 -11
- data/data/solutions/reddit/ruby/2020/15.yml +9 -9
- data/data/solutions/reddit/ruby/2020/16.yml +13 -13
- data/data/solutions/reddit/ruby/2020/17.yml +11 -11
- data/data/solutions/reddit/ruby/2020/18.yml +19 -19
- data/data/solutions/reddit/ruby/2020/19.yml +18 -18
- data/data/solutions/reddit/ruby/2020/20.yml +4 -4
- data/data/solutions/reddit/ruby/2020/21.yml +4 -4
- data/data/solutions/reddit/ruby/2020/22.yml +8 -8
- data/data/solutions/reddit/ruby/2020/23.yml +4 -4
- data/data/solutions/reddit/ruby/2020/24.yml +6 -6
- data/data/solutions/reddit/ruby/2020/25.yml +6 -6
- data/data/solutions/reddit/ruby/2021/01.yml +74 -74
- data/data/solutions/reddit/ruby/2021/02.yml +45 -45
- data/data/solutions/reddit/ruby/2021/03.yml +43 -43
- data/data/solutions/reddit/ruby/2021/04.yml +23 -23
- data/data/solutions/reddit/ruby/2021/05.yml +16 -16
- data/data/solutions/reddit/ruby/2021/06.yml +35 -35
- data/data/solutions/reddit/ruby/2021/07.yml +26 -26
- data/data/solutions/reddit/ruby/2021/08.yml +15 -15
- data/data/solutions/reddit/ruby/2021/09.yml +11 -11
- data/data/solutions/reddit/ruby/2021/10.yml +9 -9
- data/data/solutions/reddit/ruby/2021/11.yml +12 -12
- data/data/solutions/reddit/ruby/2021/12.yml +8 -8
- data/data/solutions/reddit/ruby/2021/13.yml +13 -13
- data/data/solutions/reddit/ruby/2021/14.yml +10 -10
- data/data/solutions/reddit/ruby/2021/15.yml +10 -10
- data/data/solutions/reddit/ruby/2021/16.yml +8 -8
- data/data/solutions/reddit/ruby/2021/17.yml +6 -6
- data/data/solutions/reddit/ruby/2021/18.yml +5 -5
- data/data/solutions/reddit/ruby/2021/19.yml +3 -3
- data/data/solutions/reddit/ruby/2021/20.yml +5 -5
- data/data/solutions/reddit/ruby/2021/21.yml +5 -5
- data/data/solutions/reddit/ruby/2021/22.yml +4 -4
- data/data/solutions/reddit/ruby/2021/23.yml +7 -7
- data/data/solutions/reddit/ruby/2021/24.yml +8 -8
- data/data/solutions/reddit/ruby/2021/25.yml +4 -4
- data/data/solutions/reddit/ruby/2022/01.yml +29 -29
- data/data/solutions/reddit/ruby/2022/02.yml +21 -21
- data/data/solutions/reddit/ruby/2022/03.yml +35 -35
- data/data/solutions/reddit/ruby/2022/04.yml +42 -42
- data/data/solutions/reddit/ruby/2022/05.yml +29 -29
- data/data/solutions/reddit/ruby/2022/06.yml +38 -38
- data/data/solutions/reddit/ruby/2022/07.yml +25 -25
- data/data/solutions/reddit/ruby/2022/08.yml +9 -9
- data/data/solutions/reddit/ruby/2022/09.yml +18 -18
- data/data/solutions/reddit/ruby/2022/10.yml +14 -14
- data/data/solutions/reddit/ruby/2022/11.yml +7 -7
- data/data/solutions/reddit/ruby/2022/12.yml +2 -2
- data/data/solutions/reddit/ruby/2022/13.yml +9 -9
- data/data/solutions/reddit/ruby/2022/14.yml +5 -5
- data/data/solutions/reddit/ruby/2022/15.yml +6 -6
- data/data/solutions/reddit/ruby/2022/16.yml +5 -5
- data/data/solutions/reddit/ruby/2022/17.yml +2 -2
- data/data/solutions/reddit/ruby/2022/18.yml +6 -6
- data/data/solutions/reddit/ruby/2022/19.yml +3 -3
- data/data/solutions/reddit/ruby/2022/20.yml +12 -12
- data/data/solutions/reddit/ruby/2022/21.yml +11 -11
- data/data/solutions/reddit/ruby/2022/22.yml +4 -4
- data/data/solutions/reddit/ruby/2022/24.yml +10 -10
- data/data/solutions/reddit/ruby/2022/25.yml +10 -10
- data/data/solutions/reddit/ruby/2023/01.yml +52 -52
- data/data/solutions/reddit/ruby/2023/02.yml +21 -21
- data/data/solutions/reddit/ruby/2023/03.yml +18 -18
- data/data/solutions/reddit/ruby/2023/04.yml +31 -31
- data/data/solutions/reddit/ruby/2023/05.yml +14 -14
- data/data/solutions/reddit/ruby/2023/06.yml +24 -24
- data/data/solutions/reddit/ruby/2023/07.yml +32 -32
- data/data/solutions/reddit/ruby/2023/08.yml +20 -20
- data/data/solutions/reddit/ruby/2023/09.yml +32 -32
- data/data/solutions/reddit/ruby/2023/10.yml +18 -18
- data/data/solutions/reddit/ruby/2023/11.yml +16 -16
- data/data/solutions/reddit/ruby/2023/12.yml +5 -5
- data/data/solutions/reddit/ruby/2023/13.yml +6 -6
- data/data/solutions/reddit/ruby/2023/14.yml +14 -14
- data/data/solutions/reddit/ruby/2023/15.yml +13 -13
- data/data/solutions/reddit/ruby/2023/16.yml +8 -8
- data/data/solutions/reddit/ruby/2023/18.yml +5 -5
- data/data/solutions/reddit/ruby/2023/19.yml +6 -6
- data/data/solutions/reddit/ruby/2023/20.yml +9 -9
- data/data/solutions/reddit/ruby/2023/21.yml +5 -5
- data/data/solutions/reddit/ruby/2023/22.yml +2 -2
- data/data/solutions/reddit/ruby/2023/23.yml +1 -1
- data/data/solutions/reddit/ruby/2023/25.yml +1 -1
- data/data/solutions/reddit/ruby/2024/01.yml +15 -15
- data/data/solutions/reddit/ruby/2024/02.yml +17 -17
- data/data/solutions/reddit/ruby/2024/03.yml +43 -43
- data/data/solutions/reddit/ruby/2024/04.yml +18 -18
- data/data/solutions/reddit/ruby/2024/05.yml +29 -29
- data/data/solutions/reddit/ruby/2024/06.yml +19 -19
- data/data/solutions/reddit/ruby/2024/07.yml +26 -26
- data/data/solutions/reddit/ruby/2024/08.yml +15 -15
- data/data/solutions/reddit/ruby/2024/09.yml +5 -5
- data/data/solutions/reddit/ruby/2024/10.yml +9 -9
- data/data/solutions/reddit/ruby/2024/11.yml +15 -15
- data/data/solutions/reddit/ruby/2024/12.yml +9 -9
- data/data/solutions/reddit/ruby/2024/13.yml +10 -10
- data/data/solutions/reddit/ruby/2024/14.yml +6 -6
- data/data/solutions/reddit/ruby/2024/15.yml +5 -5
- data/data/solutions/reddit/ruby/2024/16.yml +4 -4
- data/data/solutions/reddit/ruby/2024/17.yml +11 -11
- data/data/solutions/reddit/ruby/2024/18.yml +9 -9
- data/data/solutions/reddit/ruby/2024/19.yml +16 -16
- data/data/solutions/reddit/ruby/2024/20.yml +8 -8
- data/data/solutions/reddit/ruby/2024/21.yml +3 -3
- data/data/solutions/reddit/ruby/2024/22.yml +8 -8
- data/data/solutions/reddit/ruby/2024/23.yml +13 -13
- data/data/solutions/reddit/ruby/2024/24.yml +7 -7
- data/data/solutions/reddit/ruby/2024/25.yml +14 -14
- data/lib/arb/api/aoc.rb +2 -2
- data/lib/arb/cli/run.rb +2 -3
- data/lib/arb/version.rb +1 -1
- data/lib/download_solutions/api/reddit/get_serial_comments.rb +1 -1
- metadata +2 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: arnoldboy123
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnnkebn
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnnkebn
|
4
4
|
:body: |-
|
5
5
|
# Ruby Solution
|
6
6
|
|
@@ -39,7 +39,7 @@
|
|
39
39
|
This is my quick and dirty solution. Not trying to code something perfect but just good enough to do the job of giving me the result in console.
|
40
40
|
:replies: []
|
41
41
|
- :author: ignurant
|
42
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk9rkd
|
42
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk9rkd
|
43
43
|
:body: |-
|
44
44
|
Ruby:
|
45
45
|
|
@@ -75,22 +75,22 @@
|
|
75
75
|
```
|
76
76
|
:replies:
|
77
77
|
- :author: bunceandbean
|
78
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnka1xd
|
78
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnka1xd
|
79
79
|
:body: I think this has to be on purpose, as the median and mean worked for me as well. I think it probably might be tailored for computer science in the sense that converting (casting) doubles to ints floors the value?
|
80
80
|
:replies:
|
81
81
|
- :author: KT421
|
82
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkfzp0
|
82
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkfzp0
|
83
83
|
:body: That's actually dependent on language. R will round to the nearest even number unless you explicitly use `floor()` or `ceiling()`. Other languages floor it.
|
84
84
|
:replies: []
|
85
85
|
- :author: marshalofthemark
|
86
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkbq1j
|
86
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkbq1j
|
87
87
|
:body: |-
|
88
88
|
If N crabs are to your right and M crabs are to your left, then every step to the right will decrease your fuel needed by N - M. So if you plot fuel needed (y-axis) vs. horizontal position (x-axis) on a Cartesian x-y graph, it will have a slope of N - M.
|
89
89
|
|
90
90
|
The global minimum occurs when slope is 0, where there are an equal number of crabs on both sides ... and by definition that happens at the median.
|
91
91
|
:replies: []
|
92
92
|
- :author: ACProctor
|
93
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnlnn23
|
93
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnlnn23
|
94
94
|
:body: |-
|
95
95
|
I'll be honest, I forgot about Gauss. But for anyone else thinking that today is just a one-trick solution, here's how I optimized using recursion with memoization.
|
96
96
|
|
@@ -129,15 +129,15 @@
|
|
129
129
|
```
|
130
130
|
:replies: []
|
131
131
|
- :author: dtinth
|
132
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk3yry
|
132
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk3yry
|
133
133
|
:body: "```ruby\n# Ruby, 54 / 13\ncrabs = gets.split(',').map(&:to_i)\np (0..1000).map { |u| crabs.sum { |x| (x-u).abs } }.min\np (0..1000).map { |u| crabs.sum { |x| n = (x-u).abs; (n*(n+1))/2 } }.min\n```\n\nThe number 1000 was arbitrarily chosen, it was a total fluke that it worked \U0001F605"
|
134
134
|
:replies:
|
135
135
|
- :author: gurgeous
|
136
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk6jpv
|
136
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk6jpv
|
137
137
|
:body: Ha, mine is nearly identical! Only difference is that I used \_1 and crabs.max instead of 1000.
|
138
138
|
:replies: []
|
139
139
|
- :author: BluFoot
|
140
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk59fl
|
140
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk59fl
|
141
141
|
:body: |-
|
142
142
|
**Ruby** 79 bytes
|
143
143
|
|
@@ -147,7 +147,7 @@
|
|
147
147
|
```
|
148
148
|
:replies: []
|
149
149
|
- :author: marshalofthemark
|
150
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk6ds2
|
150
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk6ds2
|
151
151
|
:body: |-
|
152
152
|
**Ruby (only runs in 3.0+)**
|
153
153
|
|
@@ -161,7 +161,7 @@
|
|
161
161
|
```
|
162
162
|
:replies:
|
163
163
|
- :author: ni3t
|
164
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk9cny
|
164
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk9cny
|
165
165
|
:body: |-
|
166
166
|
You could use `map(&:to_i)` and `min_by` to shorten these up:
|
167
167
|
|
@@ -173,7 +173,7 @@
|
|
173
173
|
```
|
174
174
|
:replies: []
|
175
175
|
- :author: clarabellum
|
176
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnmfaet
|
176
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnmfaet
|
177
177
|
:body: |-
|
178
178
|
Came here feeling like "ugh this is inelegant but at least it worked, let's see what other people did" and now I feel validated because it doesn't sound like any of you are super happy with your solutions either haha
|
179
179
|
|
@@ -184,14 +184,14 @@
|
|
184
184
|
I hit my head against the wall trying to figure out why sometimes the answer was the mean and sometimes the answer was the mean + 1... so I ended up just doing a brute force search within 3 squares of the mean
|
185
185
|
:replies: []
|
186
186
|
- :author: frontpageminus
|
187
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk5fjn
|
187
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk5fjn
|
188
188
|
:body: |-
|
189
189
|
Ruby 1712/1304
|
190
190
|
|
191
191
|
[paste](https://topaz.github.io/paste/#XQAAAQB/AQAAAAAAAAARiAqGkkN7pUjVWW5QYxj2CIMqqYvXYJRPYP/bLEpwScA00QMIIzV3y5DQ9XZf+B8zWbGmR8IAPA65zDdVORbjm13caysTw9my+BdK8Rc+SFE0v/r7OwT6/8tktIMeNGOJGmZBxLpMnK21YV+uhweGcwXsY64TkluTP9YGNd+VbPVbBdxmLNF4dlQFFLm0KNRU/9cQxXGAzqWQprhZ/8sHZbg72ffmgmLtbD9WYfJXk5n7ZsX/sWOBwA==)
|
192
192
|
:replies: []
|
193
193
|
- :author: ni3t
|
194
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk90t4
|
194
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk90t4
|
195
195
|
:body: |-
|
196
196
|
### Ruby
|
197
197
|
|
@@ -210,11 +210,11 @@
|
|
210
210
|
```
|
211
211
|
:replies: []
|
212
212
|
- :author: madethemcry
|
213
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkbxsh
|
213
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkbxsh
|
214
214
|
:body: "# RUBY\n\n[georgiee/advent-of-code-2021/day-07 (GitHub)](https://github.com/georgiee/advent-of-code-2021/tree/main/day-07)\n\n# Notes\n\nOk I was SUPER fast for part 1 (well not fast enough for the leaderboard, ~10mins or so) but then part 2 got me like Day 6 got me: It was running forever. This time I had no immediate clue what was wrong. I tinkered around with the range which I calculated as `range = (input.min..input.max)` so covering the entire x-axis where the crabs are hanging around. In part 1 I was lucky and I could use `input.compact.uniq` instead but this is not working here as we might miss some ideal positions (like the `5` from the example).\n\nSo what now? Let's optimize in a classical way, maybe the code runs slow for all the given permutations. I was using `key.downto(1).inject(:+)` to add up the numbers. That's expensive so what do you do ? Cache it. I used the great `default_proc` fucntionality of the ruby hash. That's a proc invoked for not existing keys. That way I can calculate values for a new key and return previous calculations directly without calculation.`TRIANGLE_CACHE.default_proc = proc { |hash, key| hash[key] = key.downto(1).inject(:+) }`\n\nThis was the first time it worked with painful 6 or so seconds.\n\nI submitted the result but I wanted to see if I can bring that number down. When I searched for `factorial but with addition` I came across the triangle numbers which are familiar to me from statistics (but my mind did not conclude this before google). So instead of adding up all numbers manually I can shortcut and do the math with `n*(n+1)/2` \U0001F918 I removed the cache and replaced it with the direct calculation. It's now 2.7 seconds.\n\nIf I bring back the hash cache, I can shave another 0.75s probably because of the shear amount of permutations I'm processing. I had some ideas for precalculate all permutations to remove duplicates, then calculate and the group the results back to the specific positions to add them up again. But my stamina is gone for this day.\n\nSo it's 1.9s.\n\n# CODE (part 2 only)\n\n```ruby\nrequire 'benchmark'\n\npath = File.join( __dir__ , 'input.txt')\ninput = File.read(path).split(',').map(&:to_i)\n\nrange = (input.min..input.max)\n\n# create a cache for the calculation of the triangle number, saves 0.7s\nTRIANGLE_CACHE = {}\nTRIANGLE_CACHE.default_proc = proc do |hash, key|\n hash[key] = triangle_number(key)\nend\n\n# search for factorial but with addition\n# and got my hands on the name of the \"algorithm\"\ndef triangle_number(n)\n n*(n+1)/2\nend\n\ndef cost_to_align(input, position)\n input.inject(0) do |memo, value|\n memo + TRIANGLE_CACHE[(value - position).abs]\n end\nend\n\n# 1.922631 0.008752 1.931383 ( 1.942595)\nputs Benchmark.measure {\n result = range.to_a.map do |position|\n fuel = cost_to_align(input, position)\n [position, fuel]\n end\n\n puts result.min_by { _1[1]}[1]\n}\n```"
|
215
215
|
:replies: []
|
216
216
|
- :author: riffraff
|
217
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkg35y
|
217
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkg35y
|
218
218
|
:body: |-
|
219
219
|
I'm happy with the brute force ruby solution for part 2. I think one can be faster if instead of computing all values and doing #min you just terminate early when the previous value is smaller than the current one but I can't express that in a short way :)
|
220
220
|
|
@@ -232,7 +232,7 @@
|
|
232
232
|
```
|
233
233
|
:replies:
|
234
234
|
- :author: lygaret
|
235
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkh3r7
|
235
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkh3r7
|
236
236
|
:body: |-
|
237
237
|
how to go from O(n) to O(log n)? binary search!
|
238
238
|
|
@@ -263,7 +263,7 @@
|
|
263
263
|
```
|
264
264
|
:replies: []
|
265
265
|
- :author: icyFur
|
266
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkk3ah
|
266
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkk3ah
|
267
267
|
:body: |-
|
268
268
|
I did this in Ruby: For part one ([full code](https://getsturdy.com/advent-of-code-2021-uoeIDQk/browse/day07/kiril/partone.rb)) the least fuel is at the median - def median(input) sorted = input.sort len = sorted.length (sorted[(len - 1) / 2] + sorted[len / 2]) / 2 end
|
269
269
|
|
@@ -302,7 +302,7 @@
|
|
302
302
|
```
|
303
303
|
:replies: []
|
304
304
|
- :author: bobtom8482
|
305
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnlholw
|
305
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnlholw
|
306
306
|
:body: |-
|
307
307
|
Continuing trying to learn Ruby for my first job (!).
|
308
308
|
|
@@ -311,7 +311,7 @@
|
|
311
311
|
[linky](https://topaz.github.io/paste/#XQAAAQCKAwAAAAAAAAAxmwhIY/U9T3vi0RAbnIXPKO8G25aDTAtzs9PptRokuGsXXB+f8iGcRzobqJqEdB6RdPjOtf4bhTtlr/VEsbh9/Gj2J7g/UNSTfusRq973DNk7ZVkoRWqHamdfPjmc2YjbVZ0XsPgJINxElHlW2wNkTTPSvi8QqBkV68QSBTvQhsP7U9PX9U1YIDK266jldcHbnJ1eetuH5hX0krMpWHnln2eSxWKywWBRHobhzKB4IiZS8DFP7K18hO29FjLcPHRO3TCXJGCVOzYiFHxLQLYHIMdsIGAQHg7b4Ur5HnJKTfaBxfU4kUPrjO40jsRTbu6Xtb9YwX0MqrVBWOyfhbch8orUGDooYIRBsGyCTgVMJEfs2R4H0GP3llStQbh5bsMA9kBPu/GF3ve4E7XP2Pq82/lObN+Jbw59I3LXAskX8jszr8lkf5eHZy+wbP27K/qzsZs4IQZ1F8X0HKzUizgdrSAukiBoZ92yzoJsuz58wrgpHvRkRnGV1nu0wkILfm6oH+TAKEwr/kUetBusfEaLJvwCPTqLDzJ+RE6c8/+C/Gf2)
|
312
312
|
:replies: []
|
313
313
|
- :author: BramboraSK
|
314
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnlqz8g
|
314
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnlqz8g
|
315
315
|
:body: |-
|
316
316
|
My **Ruby** solution
|
317
317
|
|
@@ -342,7 +342,7 @@
|
|
342
342
|
```
|
343
343
|
:replies: []
|
344
344
|
- :author: zxywx
|
345
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk6ssa
|
345
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk6ssa
|
346
346
|
:body: |-
|
347
347
|
# Ruby
|
348
348
|
|
@@ -376,7 +376,7 @@
|
|
376
376
|
```
|
377
377
|
:replies:
|
378
378
|
- :author: zxywx
|
379
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnka24h
|
379
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnka24h
|
380
380
|
:body: |-
|
381
381
|
I realise now I could replace my brute-force fuel calculation with this:
|
382
382
|
|
@@ -387,7 +387,7 @@
|
|
387
387
|
```
|
388
388
|
:replies: []
|
389
389
|
- :author: Archer_Winter
|
390
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk7o4d
|
390
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnk7o4d
|
391
391
|
:body: |-
|
392
392
|
Ruby Solution
|
393
393
|
|
@@ -400,14 +400,14 @@
|
|
400
400
|
# part 2sums[i] = numbers.map { |num| (0..(num - i).abs).sum }.sump iendp sums.min`
|
401
401
|
:replies: []
|
402
402
|
- :author: "[deleted]"
|
403
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnklwsw
|
403
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnklwsw
|
404
404
|
:body: |-
|
405
405
|
Ruby: [https://github.com/sreedevk/advent-of-code/blob/main/ruby/2021/day7/main.rb](https://github.com/sreedevk/advent-of-code/blob/main/ruby/2021/day7/main.rb)
|
406
406
|
|
407
407
|
Elixir: https://github.com/sreedevk/advent-of-code/blob/main/elixir/lib/twenty21/day7.ex
|
408
408
|
:replies: []
|
409
409
|
- :author: CodeIsTheEnd
|
410
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkmx1t
|
410
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkmx1t
|
411
411
|
:body: |-
|
412
412
|
**Ruby** : 5:00/10:26
|
413
413
|
|
@@ -416,7 +416,7 @@
|
|
416
416
|
Tried to outsmart Part 1 and jumped to using the average instead of just being inefficient and computing everything. Turns out that'd be useful for Part 2, but I had just rounded the average, it still would've been incorrect! I messed up computing triangle numbers too (did squares first). Just bad all around.
|
417
417
|
:replies: []
|
418
418
|
- :author: ldhmachin
|
419
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkqmt1
|
419
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rar7ty/2021_day_7_solutions/hnkqmt1
|
420
420
|
:body: |-
|
421
421
|
**Ruby**
|
422
422
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: ignurant
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnudsbi
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnudsbi
|
4
4
|
:body: |-
|
5
5
|
Wow. I think I spent like 12 hours on this. I can't even remember the paths I've travelled, but each of them included "If you use bit masking, I bet there's a way you can just cycle through things and eliminate candidates and it eventually just cycles into place". Messing with bits is something I think can be very powerful, but I'm not great at thinking through. I definitely spent a fair amount of time over-planning for what my solution eventually became.
|
6
6
|
|
@@ -56,14 +56,14 @@
|
|
56
56
|
```
|
57
57
|
:replies: []
|
58
58
|
- :author: SnooConfections2453
|
59
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnrjfze
|
59
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnrjfze
|
60
60
|
:body: |-
|
61
61
|
My solution in ruby: [https://github.com/ciscou/aoc/blob/master/2021/08.rb](https://github.com/ciscou/aoc/blob/master/2021/08.rb)
|
62
62
|
|
63
63
|
As always, trying to make the solution both compact and readable.
|
64
64
|
:replies: []
|
65
65
|
- :author: zxywx
|
66
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnrs3ax
|
66
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnrs3ax
|
67
67
|
:body: |-
|
68
68
|
# Ruby
|
69
69
|
|
@@ -107,7 +107,7 @@
|
|
107
107
|
```
|
108
108
|
:replies: []
|
109
109
|
- :author: dtinth
|
110
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnoonjl
|
110
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnoonjl
|
111
111
|
:body: |-
|
112
112
|
```ruby
|
113
113
|
# Ruby, 307 / 38
|
@@ -135,7 +135,7 @@
|
|
135
135
|
[`Array#permutation`](https://ruby-doc.org/core-2.7.0/Array.html#method-i-permutation) and [`String#tr`](https://ruby-doc.org/core-2.7.0/String.html#method-i-tr) saved the day for me. Part 2 takes about 30 seconds to run. I tripped up because of the line breaks in the example that was not present in the actual input. (The code is slightly cleaned up.)
|
136
136
|
:replies: []
|
137
137
|
- :author: weiss_i_net
|
138
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnrbszu
|
138
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnrbszu
|
139
139
|
:body: |-
|
140
140
|
**Ruby**
|
141
141
|
|
@@ -185,7 +185,7 @@
|
|
185
185
|
```
|
186
186
|
:replies: []
|
187
187
|
- :author: ri7chy
|
188
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnotqnq
|
188
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnotqnq
|
189
189
|
:body: |-
|
190
190
|
[Python](https://topaz.github.io/paste/#XQAAAQArBgAAAAAAAAA0m0pnuFI8c/sCZpj3cAYdf1rmsJFkgD8wKleJtNqyXMCOhQ13+lVFP2dZxMw8i3ZaKeFIM0NkVCdUIOlsL0xIzvycUZp06Mz0PYAtpRlU/ZWO7b7Iau/lEl8G6nUyw7iV+USWzPGR1Wum/8B3cfzRJ9pTOaER/KtcDECKDJVYQmFQSNzwD19lzYl1lQW/Fr0qAC0KlBP5WrUby14MudUPXEjw/Txm11dMX7K4F+KduflJ8pGMWn7zB12WTiMLL/n7klA1uYdoOzS+dVu6o/lg+cOgdKPFlUmWxDKC8vTgQ3tjtYU3S1HwAVNxntRWhTWluOifQagXl2WRCK2gMLBzOofYi7c8djpLTB5hqIjKcqtOITqZRrXxTaXYl//2noggxvOy9cttyVM1XzbU2Y0zcF8qYC6FAyAPNifaWgO55Hk2BnYWkJ1WkHk/M63JyOdzETo5RAjUtNODRrNPeIJx350FC6dzRgmLF+9XOQ5DR/eGpRQRjndJVT9lObQLT8t40zeu3FaT9jnlr8C5QnYpT+AjLCm3PAOtbscBSDN8ryzHS8QSd45Hxu3F9JkOjeH3HgobZSPxcen2UxQRuunFlDDCtZFvn4YZmuWAcwQrECxWhr5tHO3aTH3ZAIYB6j/7hfPw7yIiD/yQH8eltqQ8uYTkzAEU1PZ18odH29hHsT969jLc4j6ishCl/77rVcA=)
|
191
191
|
|
@@ -194,18 +194,18 @@
|
|
194
194
|
used counter for checking the common letters.
|
195
195
|
:replies:
|
196
196
|
- :author: jdyarrington
|
197
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnoyz7p
|
197
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnoyz7p
|
198
198
|
:body: I stared at the problem, mostly the numbers showing the segments displayed for about 40 minutes. Then I saw the same pattern that you do in your code and came to almost the same exact methodology as you. Neat!
|
199
199
|
:replies:
|
200
200
|
- :author: ri7chy
|
201
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnpnsor
|
201
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnpnsor
|
202
202
|
:body: |-
|
203
203
|
runs in a good time as well.
|
204
204
|
|
205
205
|
your code?
|
206
206
|
:replies:
|
207
207
|
- :author: jdyarrington
|
208
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnqbgwb
|
208
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnqbgwb
|
209
209
|
:body: |-
|
210
210
|
Python
|
211
211
|
|
@@ -218,7 +218,7 @@
|
|
218
218
|
Edit: I have no clue how to format code on reddit so replaced it with a pastebin. Also adding additional thoughts/comments.
|
219
219
|
:replies: []
|
220
220
|
- :author: icyFur
|
221
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnps70y
|
221
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnps70y
|
222
222
|
:body: |-
|
223
223
|
Tricky one, at least until it clicked that it's about sets. Here is the full working solution in [Ruby](https://getsturdy.com/uoeIDQk/changes/495e69ca-c17e-4956-a0e6-0ec3c3961f7a)
|
224
224
|
|
@@ -292,7 +292,7 @@
|
|
292
292
|
It's important to populate the lookup tables in this order. [Full code here](https://getsturdy.com/uoeIDQk/changes/495e69ca-c17e-4956-a0e6-0ec3c3961f7a)
|
293
293
|
:replies: []
|
294
294
|
- :author: frontpageminus
|
295
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnoqj6s
|
295
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnoqj6s
|
296
296
|
:body: |-
|
297
297
|
Ruby 205/816
|
298
298
|
|
@@ -301,7 +301,7 @@
|
|
301
301
|
[paste](https://topaz.github.io/paste/#XQAAAQAPBwAAAAAAAAARiAqGkkN7pOxE/jDIaqDrFWcgz0npJEVu8JMye3H5Wr2Siem6T/HmXnye4iMQFreC88u4FwGGtRFQHFKYvr8DfgV4/GqZtINLzjxBN/vu3b+rz6QkckCBnspFqIvXW0CKUc4vrq8DKK8U4l67J5sSl2yrqu9a7Vg2pIugY2dX+nwErW3pO9cCrmjtrafemkIGkl8Vg6gNadXOn7cywBXKhHL+b3Fda63ZClGlQdqSKcGlT8zX4D6QDrNDWQ+YRiS+HO46Zx+y8lk5Dqe8U4pFYQSmjPfoFtCVpDESnx8Z/R4ZBcw/eTVnAFIgUFvucYjE3B9lDeKXMb9ucQJpAuxRWDQueuogMBxBexqv2IsV8j0S15Vw4Hbbl7RVys89908Lr6KUjEHHt61qzWPnBR0/7TcNXpMgAgqcNZRKwSWmNpSWJFzWzt/0wVUu1YPcPF/Nxs/QCwiylpSaQcxZg6p+hCbf4tCBJV4M44+hqEogLX321W2YBLohUKGv2Tnbj8IxHvSDlqQ9jV1OrIHmFLg5JsYMBtO3cWRH/JWxZpWjaY7GSHL+GCaqpQjz8oUvRE0HTlPgvBBIUsoBa+TXL0+2T2otfYEIF4ro6GSDR5OMufGKZHoS7W955lMSV+m2LZD1oPryhNdPWgH2Fn7iAnyTLosHFtKmaPKA3yGIuRfzUEyVXmHPFtMW4xIgqqD2aAfjg6l/Pohe1F5yVSxbTmY78TUdbBM8M6fvggbKBS5t5n6F4aP+fSHu)
|
302
302
|
:replies: []
|
303
303
|
- :author: ni3t
|
304
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnorgs4
|
304
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnorgs4
|
305
305
|
:body: |-
|
306
306
|
### Ruby
|
307
307
|
|
@@ -342,7 +342,7 @@
|
|
342
342
|
**END**
|
343
343
|
:replies: []
|
344
344
|
- :author: marshalofthemark
|
345
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnorr06
|
345
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnorr06
|
346
346
|
:body: |-
|
347
347
|
**Ruby** - second top 1000 of the year
|
348
348
|
|
@@ -402,7 +402,7 @@
|
|
402
402
|
```
|
403
403
|
:replies: []
|
404
404
|
- :author: CodeIsTheEnd
|
405
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnosop0
|
405
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnosop0
|
406
406
|
:body: |-
|
407
407
|
**Ruby** : 5:22/25:53, 338/271
|
408
408
|
|
@@ -425,7 +425,7 @@
|
|
425
425
|
Okay, maybe too complicated...
|
426
426
|
:replies: []
|
427
427
|
- :author: snowe2010
|
428
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnoynl0
|
428
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rbj87a/2021_day_8_solutions/hnoynl0
|
429
429
|
:body: |-
|
430
430
|
Ruby
|
431
431
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
---
|
2
2
|
- :author: icyFur
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/ho9vhch
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/ho9vhch
|
4
4
|
:body: My solution in [Ruby](https://getsturdy.com/advent-of-code-2021-uoeIDQk/browse/day09/kiril/solve.rb)
|
5
5
|
:replies: []
|
6
6
|
- :author: CodeIsTheEnd
|
7
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntirld
|
7
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntirld
|
8
8
|
:body: |-
|
9
9
|
**Ruby** : 4:44/10:20, 248/94!
|
10
10
|
|
@@ -19,7 +19,7 @@
|
|
19
19
|
Part 2 was fun. Good, quick, easy to understand solution, and I was able to debug pretty quickly. I treated points outside of the cave as having a height of 10 and that worked well!
|
20
20
|
:replies: []
|
21
21
|
- :author: "[deleted]"
|
22
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hnu6cc0
|
22
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hnu6cc0
|
23
23
|
:body: |-
|
24
24
|
Ruby
|
25
25
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
`Range (min … max): 396.0 ms … 579.9 ms 10 runs`
|
33
33
|
:replies: []
|
34
34
|
- :author: ignurant
|
35
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hnwljmj
|
35
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hnwljmj
|
36
36
|
:body: |-
|
37
37
|
**Ruby** Pt 2:
|
38
38
|
|
@@ -136,7 +136,7 @@
|
|
136
136
|
```
|
137
137
|
:replies: []
|
138
138
|
- :author: dtinth
|
139
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntgbwa
|
139
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntgbwa
|
140
140
|
:body: |-
|
141
141
|
Ruby, 67 / 55
|
142
142
|
|
@@ -145,14 +145,14 @@
|
|
145
145
|
I was in a hurry and wasn’t able to think of `h.times.to_a.product(w.times.to_a)` so I just write two-level for loops `(0...h).each do |i| (0...w).each j |i| …; end end`. GitHub Copilot helped a lot in preventing silly mistakes (I usually use the wrong variables when writing for loops).
|
146
146
|
:replies: []
|
147
147
|
- :author: firetech_SE
|
148
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntiico
|
148
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntiico
|
149
149
|
:body: |-
|
150
150
|
[Ruby 906/854](https://github.com/firetech/advent-of-code/blob/%F0%9F%8E%84/2021/09/basins.rb)
|
151
151
|
|
152
152
|
I felt I was unusually slow today, but still ended up in top 1000 for both parts (only second time that has happened this year). I guess having implemented BFS umpteen times (not complaining, I like BFS) for all the previous years has made me well prepared. :D
|
153
153
|
:replies: []
|
154
154
|
- :author: ni3t
|
155
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntkb9y
|
155
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntkb9y
|
156
156
|
:body: |-
|
157
157
|
### Ruby
|
158
158
|
|
@@ -218,11 +218,11 @@
|
|
218
218
|
```
|
219
219
|
:replies:
|
220
220
|
- :author: scarfaceDeb
|
221
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntoxi6
|
221
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntoxi6
|
222
222
|
:body: Interesting.. you did it without using any recursion
|
223
223
|
:replies: []
|
224
224
|
- :author: scarfaceDeb
|
225
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hnto9ze
|
225
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hnto9ze
|
226
226
|
:body: |-
|
227
227
|
**Ruby**
|
228
228
|
|
@@ -269,7 +269,7 @@
|
|
269
269
|
https://github.com/scarfacedeb/advent-of-code/blob/master/2021/day9/run.rb#L11-L51
|
270
270
|
:replies: []
|
271
271
|
- :author: frontpageminus
|
272
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntpfx8
|
272
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hntpfx8
|
273
273
|
:body: |-
|
274
274
|
Ruby 1178/7093
|
275
275
|
|
@@ -278,7 +278,7 @@
|
|
278
278
|
[paste](https://topaz.github.io/paste/#XQAAAQCEAwAAAAAAAAA5GUqKNoFH6SMqoVC09YUYkw2S+mIMHB1CSWV0VTWnX51e2y38yPqPFYGVMviZ8FB5y/cUcsDLuOHhkKbbmFYqG9sheuX5AEAeDEPRiP+Nw37hH8iTmGu5oHBy41LsFOIs+tUoQBongxBHkrf8yx5NtMifXoJotBBCd49DRK8jPUyZSriOjwAEWapdv/aLvzjCn4M1CDQKnzUBAVp138+jc3ruOfGlrPNYgWFzac/8RWzP30ilKn+FFIYamX/hgZvIn9IYRuXwhrVgxzjYMXaAkKSl/Lg8ST3V0UesQYF8crHoOhvToAVXR1mxfsrJVEw1GZxiQDpcmpX2qwy5q/A0aLyopQBc+WmhiVSPOPrI9OjpkzETcdPH03Dffq35kr2VxpjxxTmC7JfVTHZXunkTfDt5dlPtfqJG1tGXoRW/RYJoCpmUQrIUx+UkWl4wgr2pvG/gHq1DeWJcuKBl4BILH4eIpc9kZ5/9+hvz1mJk76TT33kx/lwdW0/c+ajTuOfZ8lBI58MDQaTtfsHwnOClghazEe+AaHwqRW3/UZJ8RXUlSF9OKEFNS6AVPMoQJ5yZERcUy166GDeuUEDpWtuxByxFKuglawdbIIOu1bbiurkSOBbXLJM4DSDIbqf5OVdC3MX/9pM9mg==)
|
279
279
|
:replies: []
|
280
280
|
- :author: weiss_i_net
|
281
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hnuj3ye
|
281
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rca6vp/2021_day_9_solutions/hnuj3ye
|
282
282
|
:body: |-
|
283
283
|
**Ruby**
|
284
284
|
|
@@ -1,17 +1,17 @@
|
|
1
1
|
---
|
2
2
|
- :author: "[deleted]"
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/htakj5o
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/htakj5o
|
4
4
|
:body: |-
|
5
5
|
# Ruby
|
6
6
|
|
7
7
|
[https://gist.github.com/Clashbuster/d2f7dc3246f109b987a278d98197c6f0](https://gist.github.com/Clashbuster/d2f7dc3246f109b987a278d98197c6f0)
|
8
8
|
:replies: []
|
9
9
|
- :author: icyFur
|
10
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/ho9vo1a
|
10
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/ho9vo1a
|
11
11
|
:body: Stack solution in [Ruby](https://getsturdy.com/advent-of-code-2021-uoeIDQk/browse/day10/kiril/partone.rb)
|
12
12
|
:replies: []
|
13
13
|
- :author: BluFoot
|
14
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnyezvj
|
14
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnyezvj
|
15
15
|
:body: |-
|
16
16
|
**Ruby** 181 bytes
|
17
17
|
|
@@ -30,7 +30,7 @@
|
|
30
30
|
```
|
31
31
|
:replies: []
|
32
32
|
- :author: marshalofthemark
|
33
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnyaxxl
|
33
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnyaxxl
|
34
34
|
:body: |-
|
35
35
|
**Ruby**
|
36
36
|
|
@@ -62,7 +62,7 @@
|
|
62
62
|
```
|
63
63
|
:replies: []
|
64
64
|
- :author: scarfaceDeb
|
65
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnye6zt
|
65
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnye6zt
|
66
66
|
:body: |-
|
67
67
|
**Ruby**
|
68
68
|
|
@@ -106,7 +106,7 @@
|
|
106
106
|
```
|
107
107
|
:replies: []
|
108
108
|
- :author: Spock_42
|
109
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnywep4
|
109
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnywep4
|
110
110
|
:body: |-
|
111
111
|
This is my Ruby solution to Part 2. Part 1 is similar, just a different scoring pattern. Just learning Ruby for the first time via AoC, so any C&C is appreciated.
|
112
112
|
|
@@ -130,7 +130,7 @@
|
|
130
130
|
```
|
131
131
|
:replies: []
|
132
132
|
- :author: ignurant
|
133
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnzgtbl
|
133
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnzgtbl
|
134
134
|
:body: |-
|
135
135
|
I've found the last two days to be a bit of a slog, so I felt recharged that this one was straightforward (at least for my skillset). I rather enjoyed the decoy sample answer in Pt. 1 -- My thought was "oohhhohooo!! You're bringin' it now!!!!"
|
136
136
|
|
@@ -139,14 +139,14 @@
|
|
139
139
|
[Ruby Pt. 2](https://tzarnal.github.io/Opal/#XQAAAQA3AgAAAAAAAAAoE8VAZTehaYnyuwTEaiO9AUDb7/afhxrRSAd9icyTM7XPlxTtju/5+jsKCkzkv04DoByTRxGROD4qLI5UATpNcGmondUpNWtajrRddQxTip90X2bBWlszn2h/fNUPz2qXseqes5e7KHuniHH80b/Yc9AHgpmyg50G2/yUDzH4jETOs7I/PnrJCAC34SApsl/bIrNjpJcVrOXnCuuY+Ef5QcevxBZiLYiMVE3RXSG5ckZ9527ttVO1A811aIiqHq2ueJ2IwC+PAzO3IXQDmChIoD9lsrShdx7yqRDstYqFlaGjb8RcHkhXyqvuRvhCmiaraAyQaU5yFHMWxBZB1rX6zscUgaTNiUOYFr7i4gksOBD2Lfu9N922uzpzC3jnG6qhIereIv6th4ihmORZ2buUV5L/8DjY3Q==)
|
140
140
|
:replies: []
|
141
141
|
- :author: ndnenkov
|
142
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnzwb46
|
142
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnzwb46
|
143
143
|
:body: |-
|
144
144
|
**Regex (Ruby)**
|
145
145
|
|
146
146
|
https://gist.github.com/ndnenkov/3e003f0ea8b91b91d8e6c8351bdfefe8
|
147
147
|
:replies: []
|
148
148
|
- :author: frontpageminus
|
149
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnyad2r
|
149
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rd0s54/2021_day_10_solutions/hnyad2r
|
150
150
|
:body: |-
|
151
151
|
Ruby 1094/951
|
152
152
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
---
|
2
2
|
- :author: icyFur
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/hoaazas
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/hoaazas
|
4
4
|
:body: My solution in [Ruby](https://getsturdy.com/advent-of-code-2021-uoeIDQk/changes/47771b9e-e206-47cc-92c7-79688a38d96b)
|
5
5
|
:replies: []
|
6
6
|
- :author: scarfaceDeb
|
7
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3f5kw
|
7
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3f5kw
|
8
8
|
:body: |-
|
9
9
|
**Ruby**
|
10
10
|
|
@@ -64,15 +64,15 @@
|
|
64
64
|
https://github.com/scarfacedeb/advent-of-code/blob/master/2021/day11/run.rb
|
65
65
|
:replies:
|
66
66
|
- :author: ignurant
|
67
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho48vq5
|
67
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho48vq5
|
68
68
|
:body: "`repeated_permutation` There we go! I spent like 15 minutes annoyed that I couldn’t Ruby up my directions array. I was trying varieties of `permutation` and `combinations` and zip and such. I had not previously seen _repeated_ permutation. Just what the Dr. ordered!"
|
69
69
|
:replies:
|
70
70
|
- :author: scarfaceDeb
|
71
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho4h6pt
|
71
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho4h6pt
|
72
72
|
:body: "Yeah, I found so many useful tricks and lesser known methods in Ruby stdlib in the last 10 days too \U0001F600"
|
73
73
|
:replies: []
|
74
74
|
- :author: madethemcry
|
75
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3d5si
|
75
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3d5si
|
76
76
|
:body: |-
|
77
77
|
# RUBY
|
78
78
|
|
@@ -105,18 +105,18 @@
|
|
105
105
|
I think a custom enumerator would make sense here. Then you could write like so for part 1 `cave.take(100)`and for part 2 `cave.take_while`. Both read fantastic. Time is up for today so I won't refactor that but I liked the day very much!
|
106
106
|
:replies: []
|
107
107
|
- :author: ignurant
|
108
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3ila0
|
108
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3ila0
|
109
109
|
:body: |-
|
110
110
|
I enjoyed this one quite a bit. Somewhat inspired by the DragonRuby Game Toolkit, I modeled it as a world with mobs, so pretty literally.
|
111
111
|
|
112
112
|
[Ruby pt 2](https://tzarnal.github.io/Opal/#XQAAAQAFCAAAAAAAAAAxmwhIY/VC+lD6cQOd9lyYAPDWpaReqe9sGQ0BG7rP377TcEubHCvPC0CdwEGG2DqBjJUjG9Qcu7O+lL54KYOxOEJM7AcW7Pd8w7FxmoLcR2zO1eCiO0FZqwtNsUbeQ6sWzT6C/RhB2q0AOugEPQy5xCe5GC1oGJxV01hET95B00Lw8Rg6cyqlVXgA++bbrcnY4G0Libb8Eqbxto4/CzYdUgka+xU7+1wCx+wI1mk7f5I2Pfp/7b/VRoGwr7x65ZzNo8uZBWTXrf8t9sqBe7zOcbPr7pqBzX2amlOVi86MBcXc/V8enThbmQV47A0BDbrBAam46e2k5TuYyDAybVJSMQ9Vp1dHTq+ET3W9wdNAVxcbxk6Tb8RyWBUxL0GHNij+ll5Q9vBbL7XUwc9mOewPBCIfrUD0I465DdatsUVIaMnJe1ifC4xeOG/2/mhhmGbrapJA+4tjC/DUMzu8cTyjqv9CnVsQVI4dUmqGEa8TxZczZKglrS/o69sI0hMpXOqt8Zy69NWcVCGswK6uTb4llvmlb0FG2nvfDL6TyMlMktDLIivE3xobs94pj28PvKl+GrKdicGRvG+wmcRqlozp3ps7+gxXcBSfxacDh4BM0WhBp7A1kMPgJnXcdddZ6vjOZbt1XG6FeFPw052rrKi/KJYzXlbzTucPPChFG7+x17fq0tWtlB5/r9z1iKDpzawLFyUCL8PRDGYfltcwuBcMEKQ/+MaRFTNw3cZ8sIkFmkSvGL72MJNZTcM+BnPgNNxUdCM1VW0LaLa+O9DX8SOjXJBUgb/3IO0VtEzkPJVaw5mOU2lWY7Ok8HBls4TJMvL2MQTYphhvSXzeYylc5IZYS7cHfuBxZhB0mVTwlyIwyKaj3QEMwmJA2jHYeITH8AV/WDy9B7/qY/vpr1c3swpp0NmyAw+MIsylAXCEt0wpRwegHOnCLKb2KZ4IRScn0CeY0b/aXYJ6kFEEUkcskVV+hzQ0Fyf+AOAt5ujCiQN/OK4zYsVyOhJFEt6TVVQjY4U0jgJroo5Bbl1eSg+VE66kG7jSv4fzBJtn3ddGDXiefP78KG7S)
|
113
113
|
:replies:
|
114
114
|
- :author: conthomporary
|
115
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3j7po
|
115
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3j7po
|
116
116
|
:body: 'All right, I''ll admit it: "throw :MY\_EYES!" got a chuckle out of me'
|
117
117
|
:replies: []
|
118
118
|
- :author: '442401'
|
119
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3py2s
|
119
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3py2s
|
120
120
|
:body: |-
|
121
121
|
**Ruby**
|
122
122
|
|
@@ -125,18 +125,18 @@
|
|
125
125
|
https://github.com/fig/Advent-of-Code/blob/main/2021/Day11/solution.rb
|
126
126
|
:replies: []
|
127
127
|
- :author: frontpageminus
|
128
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho34hw7
|
128
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho34hw7
|
129
129
|
:body: |-
|
130
130
|
Ruby 746/640
|
131
131
|
|
132
132
|
[paste](https://topaz.github.io/paste/#XQAAAQD5AwAAAAAAAAA2mEpiKBEva3oI7tVd9n7D3wNtbmwq32cmfy4Y74dHhdKFKKEoq7i2+I0L99HPs2sbZTY+fHeCVZlf/VgJb0PVyQlFo+sOcvoMcZPwKTjXY2RCOfFIJZQfjmHRYyRfseBHsxipEyQ7snZdsfuICl5bp6Wkck68u4kQcM7qWcHWT1zD2Zgd7IXFshVjwpJQUdbl2HZcJ4DTLJzChhwDbRX2s84FwEx6VQD3L8z9kjLoTTtrZ7V0T8n61Ei6eBb55LAusH0b31KKCMutu37h5D6SN5CkwDMo/sMnECDyB61EI40qDMHAVkIw+xFPuUMt96gi9S69B5jdrc559kEvLTT6Q3MThRK+8XVJi6ZDf03yg/WtoSBUzyKqR3xKQVx/bF3nXdWrHdRuhLOX1iq4JT77Pr5jodum9DPDTlSaM/BmTmYti8j2MGJt/7dIAPeaUBhNVf/fqYxw)
|
133
133
|
:replies: []
|
134
134
|
- :author: dhruvasagar
|
135
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3fwjr
|
135
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho3fwjr
|
136
136
|
:body: Ruby - https://github.com/dhruvasagar/comp/blob/master/adventofcode/2021/day11/day11.rb
|
137
137
|
:replies: []
|
138
138
|
- :author: hrunt
|
139
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho41e39
|
139
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho41e39
|
140
140
|
:body: |-
|
141
141
|
**Python 3**
|
142
142
|
|
@@ -145,6 +145,6 @@
|
|
145
145
|
Not a lot to say about this one. For square grids like this, I find using a dictionary of (x, y) coordinates is cleaner than using nested lists. Once I built the step function to serve Part 1, Part 2 was a breeze.
|
146
146
|
:replies:
|
147
147
|
- :author: kupuguy
|
148
|
-
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho435k7
|
148
|
+
:url: https://www.reddit.com/r/adventofcode/comments/rds32p/2021_day_11_solutions/ho435k7
|
149
149
|
:body: You don't need the extra parentheses `grid[(x, y)]` is cleaner if you just write `grid[x, y]`. You are right about the dict though; though I started using nested lists then quickly switched to a dict.
|
150
150
|
:replies: []
|