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: LyleiLanar
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hnuv4a2
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hnuv4a2
|
4
4
|
:body: |-
|
5
5
|
My Ruby solution
|
6
6
|
|
@@ -13,7 +13,7 @@
|
|
13
13
|
(I love unnecessary long code in Ruby :D)
|
14
14
|
:replies: []
|
15
15
|
- :author: icyFur
|
16
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hnr64nw
|
16
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hnr64nw
|
17
17
|
:body: |-
|
18
18
|
Day 4 in [Ruby](https://getsturdy.com/advent-of-code-2021-uoeIDQk/browse/day04/kiril/day4.rb)
|
19
19
|
|
@@ -67,7 +67,7 @@
|
|
67
67
|
```
|
68
68
|
:replies: []
|
69
69
|
- :author: snowe2010
|
70
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hna4l0i
|
70
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hna4l0i
|
71
71
|
:body: |-
|
72
72
|
# Ruby
|
73
73
|
|
@@ -141,7 +141,7 @@
|
|
141
141
|
```
|
142
142
|
:replies: []
|
143
143
|
- :author: firetech_SE
|
144
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5wr4x
|
144
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5wr4x
|
145
145
|
:body: |-
|
146
146
|
[Ruby 165/328](https://github.com/firetech/advent-of-code/blob/%F0%9F%8E%84/2021/04/bingo.rb)
|
147
147
|
|
@@ -156,7 +156,7 @@
|
|
156
156
|
:)
|
157
157
|
:replies:
|
158
158
|
- :author: Sharparam
|
159
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5xg2l
|
159
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5xg2l
|
160
160
|
:body: |-
|
161
161
|
I came up with the same win check :D
|
162
162
|
|
@@ -165,11 +165,11 @@
|
|
165
165
|
448/1336 on leaderboard. I had a bug for part 2 that took me forever to find and delayed that massively (I wasn't saving the marked numbers at the time board won, so each board got multiplied with the final state of marked numbers instead).
|
166
166
|
:replies:
|
167
167
|
- :author: firetech_SE
|
168
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5xxa3
|
168
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5xxa3
|
169
169
|
:body: I had a similar bug for part 2, making me submit one wrong answer (because I didn't test the example first). I was multiplying the unmarked numbers of the last board with the number that caused the penultimate board to win... Obviously not the right answer in hindsight. :P
|
170
170
|
:replies: []
|
171
171
|
- :author: MuumiJumala
|
172
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5vakq
|
172
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5vakq
|
173
173
|
:body: |-
|
174
174
|
Ruby 31/169
|
175
175
|
|
@@ -214,14 +214,14 @@
|
|
214
214
|
```
|
215
215
|
:replies: []
|
216
216
|
- :author: frontpageminus
|
217
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5xnb6
|
217
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5xnb6
|
218
218
|
:body: |-
|
219
219
|
Ruby (1663/1458)
|
220
220
|
|
221
221
|
[paste](https://topaz.github.io/paste/#XQAAAQBkBQAAAAAAAAA5GUqKNoFH6SMqoVC09YUYnzPWhqlH2+Hr8Fo0LWObqf/7A64y1PK3tmghdoGJvrywmmWmMpIWX+juaXZ1wcHhaQoyKpYomldzUsxTPEnSopgCgcPve52gApoUelT97axtHQbkCEsHVjaIw2W8ChFDAmNgS241pm8hq4ZuzHRMtK7DHvlLoKsFaBLZgwCdDPmmePzD4IuKDuSGoEwsjfrT6rUfMPKaIrs6/9XJLtCl+dEoHJrIZ0B5lS5FcnnQDWi0vh9FKkwV88xeArrK+LdLY9Kq/WRNL5vAzH7DzPQgu4zONrrPRfRYZEL4OPu33lYRj+drw2mDNZ2nBtXN5k/5GYfhL7p5eiy3E8i4vxJ5MkhgqY+jy0IAWkFWfqOqvv6K/STNPpIxSxdIIZhSMw/CAG1GPuNXq+RNmmgM7GPhMxoNREtUglZfZy+t4OZy4C2mcBaS8hl/LI5YTQMR/qdQHDqK4Ki9XraY3JIK+CwwBHWm2QAsOl/uClF/RmFhA/swZDR1kvG/tLuqkQXmcpWQPQys4CNZJdAzN0kOYLQ9BjUTGgGqGYHTPbqau7UMq4hTfnaFpFILB0uQ7fP1jjbPTBSwfZUWf6/jfEH6MG2YLPKRcsHTPhwDDDrozvv9P5rZw/bi0vsYR66oXoCN7mSgREw72LILWdaCBVQtD12oGY4QQc/2iKYU8O/RK7Nhc9CvoNaSRc/U3vXzxOKj0F17jSjf28A4Lq8U2dXTEszULufziZXE42ZtvFIxAoJhyyf+EWr+)
|
222
222
|
:replies: []
|
223
223
|
- :author: BluFoot
|
224
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5ynqb
|
224
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5ynqb
|
225
225
|
:body: |-
|
226
226
|
**Ruby 234 bytes** (331/181)
|
227
227
|
|
@@ -240,7 +240,7 @@
|
|
240
240
|
```
|
241
241
|
:replies: []
|
242
242
|
- :author: prafster
|
243
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn9w2v5
|
243
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn9w2v5
|
244
244
|
:body: |-
|
245
245
|
## Julia
|
246
246
|
|
@@ -274,15 +274,15 @@
|
|
274
274
|
```
|
275
275
|
:replies: []
|
276
276
|
- :author: dtinth
|
277
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5uk84
|
277
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn5uk84
|
278
278
|
:body: "Ruby, 103/78\n\n[paste](https://topaz.github.io/paste/#XQAAAQDKAgAAAAAAAAA3HUndk+qmj5/Fy3M/zxYA0ZSRDHVvs77FAAYy3AgE7aazPBVUel9aQhsWVG6vSOGPTWnkKEODU0AvjN6HssBAnxKHYOLUnt/hXpcGJta6dQiazS5yzvrz/GNvpXoV/zQXWnJDKsMS0C2UwMjJ4dHDE8Zta9A2BCVJOwfd+axMf+jIz9H5og04A5p7sMc3VCZjI2eZ7vNvUQoydExKAqKydz9SxjasJHKzq+5qh8QGEG/JyL2qHwglp4iQ0Oy+Eal36iZgLPlT07DLBUzpxBpN+TwhSvZtnpaL/PAccWQIPGazYXxuUHVOjUtLkklcTZdvScInNkQ90N5Hvv72Vks4BPq5Huk55S6KyvVGILVrhssIQLSzq5P9VzUSVfKaDvuyzZ4BQxvPwT9tHtFLdl03f+pJuro4I9snxe4nt2GGeoI/Mg4GAqTfyiIotxq0j7YswiOxh/gkxolo+M4EzUN8X3yWrGIptoHqlbcwQsR5v9SX+ieA617tx6v5RD/giwmnPIV/LHyp5f/AZCA+)\n\nWhen the board is received, I generated a set of numbers that, if were all called, would resulted in a winning board, which is `data + data.transpose`.\n\nWhen it comes to simulation sometimes using OOP helps me think more clearly. I tripped up because I recently learned about `_1` `_2` in Ruby, but don’t know how to nest them. \U0001F602 (Edit: [Nesting numbered parameters is not allowed](https://bugs.ruby-lang.org/issues/17167))"
|
279
279
|
:replies:
|
280
280
|
- :author: ni3t
|
281
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn62qel
|
281
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn62qel
|
282
282
|
:body: sorry for tripping you up like that!!
|
283
283
|
:replies: []
|
284
284
|
- :author: ni3t
|
285
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn62c6r
|
285
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn62c6r
|
286
286
|
:body: |-
|
287
287
|
### Ruby
|
288
288
|
|
@@ -301,14 +301,14 @@
|
|
301
301
|
(board + board.transpose) opens up a whole new approach of just checking inputs, never even thought of it.
|
302
302
|
:replies: []
|
303
303
|
- :author: ignurant
|
304
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn64f25
|
304
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn64f25
|
305
305
|
:body: |-
|
306
306
|
**Ruby**
|
307
307
|
|
308
308
|
[Very straightforward boring implementation](https://tzarnal.github.io/Opal/#XQAAAQA9BQAAAAAAAAAxmwhIY/U8uCvV3MBTRcLmg+3/UZp6nzdBmHqJnigx6N8zdlE0Prd9rod6fg6O45LH2CEcTIce6Q7nzm9yIQ6Dg8/gJ45Eevtmo9v2hPx2fDjUxXAADuAr8DCXLyxRSSni9mA3GQXzpaj38zpREqz5jAdOQHXh+j02p2yYlfHhMgkweg7uZxALALEI4kRnod64/N5b/pOApEau6Plvx99C72UNH3aazlUtQGzUqUQa7Ulfm1oFpiRHQ1Bv5sROoqVYd95guiNh5/zIzE9EUqbVs+hUhFkLkgyytHBK2AZukUY6y7p7oRcSttM9Y2qYL8BzyFw9Y+k2qYoboQlHZocHer/7zqYR1UD4tDy96G2Ou/zXt9C+wLzSvp7LRBg7qM/6p4DuWfoOOoqTjFgYcS3SLHizrVLABkZMnBedFsZ9nO8DXo+xGNPsxEyqFzddnYQMsv6fwLKWUxktUMaQXKfWjgvBSTgqOCft5FQLKNly5GNrpFp6vOyEHeZOKEXO3LsYErj9u3OfnfCquUu9X2gyjCQo62Hm6MLLLikb046ttVFXdTyR56DkiEF2phIX/SpZyC/0mXMBeI2N4Oxooko2RFawgEXdQq+NKmsensxJvkjhqZ6UeuJBAzY1ceHJDP+FEBbuYkUEqADf197EaSeLHC8LEQmKHjP/0V0CJQ==) class-based kinda game thing
|
309
309
|
:replies:
|
310
310
|
- :author: madethemcry
|
311
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn64wf9
|
311
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn64wf9
|
312
312
|
:body: |-
|
313
313
|
Very nice, very elegant. I went the same road with `transpose` and `any` but less elegant. You seem to be pretty fluent in Ruby, I'm not that fluent. I enjoy your result very much and I learned a few bits. Thank you!
|
314
314
|
|
@@ -317,21 +317,21 @@
|
|
317
317
|
Edit: Your source has a wrong variable copied, find `called_number` which should be `number` in `dobb`
|
318
318
|
:replies:
|
319
319
|
- :author: ignurant
|
320
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn7886b
|
320
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn7886b
|
321
321
|
:body: |-
|
322
322
|
Thank you for the nice note! You must have grabbed that right after I posted it -- I caught that var and edited it before I saw your reply -- I thought I could sneak it through! :doh:.
|
323
323
|
|
324
324
|
This is my first time participating in this kind of thing, and it's really interesting (and humbling) to look at other solutions. Often times my main take-away (particularly yesterday!) has been: I overthink things way too much.
|
325
325
|
:replies: []
|
326
326
|
- :author: jeffers0n
|
327
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn8hz4i
|
327
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn8hz4i
|
328
328
|
:body: |-
|
329
329
|
[Ruby Solution](https://git.doublehack.me/s00ner/AoC2021/src/branch/master/day04/solution.rb)
|
330
330
|
|
331
331
|
Part 2 was pretty easy after I finished part 1.
|
332
332
|
:replies: []
|
333
333
|
- :author: masterarms
|
334
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn8i7bw
|
334
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn8i7bw
|
335
335
|
:body: |-
|
336
336
|
Ruby
|
337
337
|
|
@@ -378,7 +378,7 @@
|
|
378
378
|
```
|
379
379
|
:replies: []
|
380
380
|
- :author: madethemcry
|
381
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn62yi9
|
381
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn62yi9
|
382
382
|
:body: |-
|
383
383
|
# RUBY
|
384
384
|
|
@@ -473,7 +473,7 @@
|
|
473
473
|
```
|
474
474
|
:replies:
|
475
475
|
- :author: ignurant
|
476
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn7af5j
|
476
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn7af5j
|
477
477
|
:body: |-
|
478
478
|
I like your project layout, and I think I'm going to do that from now on. The retrospective readme per problem is a nice touch!
|
479
479
|
|
@@ -482,14 +482,14 @@
|
|
482
482
|
Thanks for sharing your notes -- I find it inspiring!
|
483
483
|
:replies: []
|
484
484
|
- :author: "[deleted]"
|
485
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn64g7t
|
485
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn64g7t
|
486
486
|
:body: |-
|
487
487
|
Ruby
|
488
488
|
|
489
489
|
https://github.com/sreedevk/advent-of-code/blob/master/ruby/2021/day4/main.rb
|
490
490
|
:replies: []
|
491
491
|
- :author: gurgeous
|
492
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn65fk0
|
492
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn65fk0
|
493
493
|
:body: |-
|
494
494
|
Ruby
|
495
495
|
|
@@ -521,7 +521,7 @@
|
|
521
521
|
```
|
522
522
|
:replies: []
|
523
523
|
- :author: l_ugray
|
524
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn6uuot
|
524
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r8i1lq/2021_day_4_solutions/hn6uuot
|
525
525
|
:body: |-
|
526
526
|
Ruby. The full code is at [https://github.com/lugray/advent\_of\_code/blob/main/2021/day04.rb](https://github.com/lugray/advent_of_code/blob/main/2021/day04.rb), but I'm particularly prod of how this looks:
|
527
527
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: "[deleted]"
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hpa1tzv
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hpa1tzv
|
4
4
|
:body: |-
|
5
5
|
# Ruby
|
6
6
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
Reddit code block is acting terribly for me, so it's a gist
|
10
10
|
:replies: []
|
11
11
|
- :author: el_daniero
|
12
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnvyn4b
|
12
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnvyn4b
|
13
13
|
:body: |-
|
14
14
|
# Ruby
|
15
15
|
|
@@ -54,7 +54,7 @@
|
|
54
54
|
```
|
55
55
|
:replies: []
|
56
56
|
- :author: icyFur
|
57
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnikn2s
|
57
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnikn2s
|
58
58
|
:body: |-
|
59
59
|
My solution in Ruby - [Part One](https://getsturdy.com/uoeIDQk/browse/day05/kiril/partone.rb) and [Part Two](https://getsturdy.com/uoeIDQk/browse/day05/kiril/parttwo.rb)
|
60
60
|
|
@@ -75,7 +75,7 @@
|
|
75
75
|
```
|
76
76
|
:replies: []
|
77
77
|
- :author: dtinth
|
78
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnagdcv
|
78
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnagdcv
|
79
79
|
:body: |-
|
80
80
|
Ruby, 43 / 66
|
81
81
|
|
@@ -87,7 +87,7 @@
|
|
87
87
|
- You can use Array (and other objects) as hash keys: `o[[x, y]] += 1` (Arrays are ‘hashable’ by its contents)
|
88
88
|
:replies: []
|
89
89
|
- :author: BluFoot
|
90
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnaltum
|
90
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnaltum
|
91
91
|
:body: |-
|
92
92
|
**Ruby 132 bytes**
|
93
93
|
|
@@ -105,11 +105,11 @@
|
|
105
105
|
```
|
106
106
|
:replies:
|
107
107
|
- :author: madethemcry
|
108
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnat1ud
|
108
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnat1ud
|
109
109
|
:body: "Thank you for the operator link, this will get handy again a moment of \"of course\" Ruby handles this for us \U0001F64F"
|
110
110
|
:replies: []
|
111
111
|
- :author: frontpageminus
|
112
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnai52y
|
112
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnai52y
|
113
113
|
:body: |-
|
114
114
|
Ruby 774/1351
|
115
115
|
|
@@ -118,11 +118,11 @@
|
|
118
118
|
[paste](https://topaz.github.io/paste/#XQAAAQCbAwAAAAAAAAAznIlVuhcHbK2J37EK0D01waEli+PuxxfOQUp6oLHODnHI1hs7oWmAsckx4ZmoAMFRkgJmIaQq4SuFx07Kx+M/rBNLtwAr3ATDsd5MeLP9tbYow1GpaCFosRYt2f6Jl3rr5t4UaQJx7G9PmHkC+GH0iki6pgy78aiFQXRtDCX4QEUkundfBjHDGGjiJAyabFJoP9ObwbRfjvtzfrjCkGvBGIywYf3V5R8mi76aObLKHQaJ6wVaji7oqXcmKFDBGASKMG13/k0vpHBFyrV6i1k6qhWdvZ2jrfIKGX0Oe4dmX4pmZGQK46xpHz8RqWO9MSo85M79RQ8HEYVswayvRtmXMY2dZWY8eqTKz6uFbxq4lSO6awKSrw9F69KHnfq66ATWFaTOGbixDDrSWJ8h1yc2wkKd1I2IWPXFhu+q9gWCWJSYI1jbUTaxVQEpb/FKb++97z62efNuRCZ/bjdvLPC0dzx0340sNKqHp1SVQZcslgvLEs+rm7Cz0Bn4ng9qb3ZO795Pb9nnhtxlb02K+RgZ4K13b5bFsq0/2GFfjOE+vrUm1YblENLrtdNgWspCsDyvSh+IH0IsKOfgkAurugkzLf/DfVAA)
|
119
119
|
:replies:
|
120
120
|
- :author: ni3t
|
121
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnajzv1
|
121
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnajzv1
|
122
122
|
:body: Wasted a good couple of minutes racking my brain on why `(1..2).reverse` wouldn't work... ugh
|
123
123
|
:replies: []
|
124
124
|
- :author: ni3t
|
125
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnajrlp
|
125
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnajrlp
|
126
126
|
:body: |-
|
127
127
|
### Ruby
|
128
128
|
|
@@ -133,7 +133,7 @@
|
|
133
133
|
Just used a simple hash map with coordinates as keys.
|
134
134
|
:replies: []
|
135
135
|
- :author: marshalofthemark
|
136
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnal7vo
|
136
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnal7vo
|
137
137
|
:body: |-
|
138
138
|
**Ruby**
|
139
139
|
|
@@ -161,7 +161,7 @@
|
|
161
161
|
```
|
162
162
|
:replies: []
|
163
163
|
- :author: '0x8b'
|
164
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnazp4e
|
164
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnazp4e
|
165
165
|
:body: |-
|
166
166
|
# Ruby
|
167
167
|
|
@@ -194,7 +194,7 @@
|
|
194
194
|
```
|
195
195
|
:replies: []
|
196
196
|
- :author: johnboker
|
197
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnc8yfb
|
197
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnc8yfb
|
198
198
|
:body: |-
|
199
199
|
Still learning ruby, comments welcome.
|
200
200
|
|
@@ -203,14 +203,14 @@
|
|
203
203
|
- edit: fixed link
|
204
204
|
:replies: []
|
205
205
|
- :author: SnooConfections2453
|
206
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hndblo6
|
206
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hndblo6
|
207
207
|
:body: |-
|
208
208
|
My solution in ruby: https://github.com/ciscou/aoc/blob/master/2021/05.rb
|
209
209
|
|
210
210
|
Kinda looking for minimizing amount of lines of code while keeping a good enough readability
|
211
211
|
:replies: []
|
212
212
|
- :author: "[deleted]"
|
213
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hndirfq
|
213
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hndirfq
|
214
214
|
:body: |-
|
215
215
|
Got a late start on this one. Here's a ruby solution:
|
216
216
|
|
@@ -275,11 +275,11 @@
|
|
275
275
|
```
|
276
276
|
:replies: []
|
277
277
|
- :author: madethemcry
|
278
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnaq38q
|
278
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnaq38q
|
279
279
|
:body: "# RUBY\n\n[georgiee/advent-of-code-2021/day-05 (GitHub)](https://github.com/georgiee/advent-of-code-2021/tree/main/day-05)\n\n# Notes\n\nReading coordinates and intersections I wanted to use linear algebra because I like the aesthetics of math but I realized pretty quickly that this won't help here because of parallel lines. I ditched it but in retorspective I would have still helped me because I could have prettier iterations. This is a mess now, because it's super, super naive as I had no time to research of think about prettier methods hidden in the ruby toolset (my daughter waking up any time is like a Damocles sword while coding the challenge \U0001F601)\n\nWell, what strategy did I follow without linear algebra? Filling the grid by calculating all the coordinates between the points and then I could stick to the ruby elegance of handling arrays. I could basically count the amount of intersections by finding the count of coordinates that are the same (with `array#tally`) and then I used `array#count` to count those with a value (in the hash given by tally) greater or equal 2.\n\nI had this beauty very quickly `coords.map(&:spread).compact.flatten(1).tally.values.count{ _1 >= 2 }` where `spread` is my custom grid filling method. I learned about the shortcut `_1` on a previous day in someone else's challenge and found the awesome tally in the docs during the first 1-2 days.\n\nI struggled a lot more with the loop building. I wanted to use ranges but they are useless for negative values and so it got super naive. Anyway, part 1 & 2 done ✅\U0001F64C\n\n# CODE (part 2 only)\n\n```ruby\nrequire 'ostruct'\n\npath = File.join( __dir__ , 'input.txt')\ninput = File.read(path)\n\nclass Vector\n attr_accessor :p1, :p2\n\n def initialize(p1, p2)\n @p1 = p1\n @p2 = p2\n end\n\n def dy\n @p2.y - @p1.y\n end\n\n def dx\n @p2.x - @p1.x\n end\n\n def dir_y\n if dy.zero?\n 0\n else\n dy.positive? ? 1 : -1\n end\n end\n\n def dir_x\n if dx.zero?\n 0\n else\n dx.positive? ? 1 : -1\n end\n end\n\n def diagonal?\n !(@p1.x == @p2.x || @p1.y == @p2.y)\n end\n\n # get all coordinate covered by this vector (diagonals are empty)\n def spread\n items = []\n\n ([dx.abs, dy.abs].max + 1).times do |index|\n items << [@p1.x + dir_x * index, @p1.y + dir_y * index]\n end\n\n items\n end\nend\n\nCOORD_FORMAT = /((\\d+),(\\d+)) -> ((\\d+),(\\d+))/.freeze\n\ncoords = input.split(\"\\n\").map { _1.match(COORD_FORMAT) }.map {\n Vector.new(\n OpenStruct.new(x: _1[2].to_i, y: _1[3].to_i),\n OpenStruct.new(x: _1[5].to_i, y: _1[6].to_i)\n )\n}\n\n# fill the grid and count the duplicate coordinates (intersections)\ncoverage = coords.map(&:spread).compact.flatten(1).tally\nresult = coverage.values.count{ _1 >= 2 }\n\nputs result\n```"
|
280
280
|
:replies: []
|
281
281
|
- :author: "[deleted]"
|
282
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnasnx2
|
282
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9824c/2021_day_5_solutions/hnasnx2
|
283
283
|
:body: |-
|
284
284
|
Ruby (PART 1 & PART 2)
|
285
285
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
---
|
2
2
|
- :author: "[deleted]"
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hphvchn
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hphvchn
|
4
4
|
:body: |-
|
5
5
|
# RUBY
|
6
6
|
|
7
7
|
[https://gist.github.com/Clashbuster/ff7ef7c5bb72b156bc9ed30d89e68525](https://gist.github.com/Clashbuster/ff7ef7c5bb72b156bc9ed30d89e68525)
|
8
8
|
:replies: []
|
9
9
|
- :author: jtgorn
|
10
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnx8b4i
|
10
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnx8b4i
|
11
11
|
:body: |-
|
12
12
|
# inovative solution (Ruby)
|
13
13
|
|
@@ -33,7 +33,7 @@
|
|
33
33
|
```
|
34
34
|
:replies: []
|
35
35
|
- :author: petercooper
|
36
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnsddpo
|
36
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnsddpo
|
37
37
|
:body: |-
|
38
38
|
**Ruby**
|
39
39
|
|
@@ -48,7 +48,7 @@
|
|
48
48
|
```
|
49
49
|
:replies: []
|
50
50
|
- :author: bobtom8482
|
51
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnle3yw
|
51
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnle3yw
|
52
52
|
:body: |-
|
53
53
|
Trying to learn Ruby for my first job (!) so this is my attempt - no help for the first time which is fun
|
54
54
|
|
@@ -88,7 +88,7 @@
|
|
88
88
|
```
|
89
89
|
:replies:
|
90
90
|
- :author: jtgorn
|
91
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnwwma9
|
91
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnwwma9
|
92
92
|
:body: |-
|
93
93
|
```ruby
|
94
94
|
(0..7).each { |i| @map[i] = @map[i + 1] }
|
@@ -98,7 +98,7 @@
|
|
98
98
|
can be written as `@map.rotate`
|
99
99
|
:replies: []
|
100
100
|
- :author: ignurant
|
101
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnffzni
|
101
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnffzni
|
102
102
|
:body: |-
|
103
103
|
I first solved with a typical "simulate each fish" like a lot of other folks I'm reading about. Overcoming the exponential growth issue was exhilarating. I was demoralized for a few minutes, assuming there was some hidden super easy math trick that can spit the answer out with a simple function. After a minute of stepping away, I realized that I just need the number of fishes in each stage and can promote the whole crew each tick. It was a rollercoaster, and I felt awesome thinking about all of the wasted compute power and ram being used to essentially perform the same lifecycle on all those individual fish.
|
104
104
|
|
@@ -124,48 +124,48 @@
|
|
124
124
|
```
|
125
125
|
:replies:
|
126
126
|
- :author: runforfun721
|
127
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfglxy
|
127
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfglxy
|
128
128
|
:body: 'TIL #tally and #transform\_keys! Thanks for sharing!'
|
129
129
|
:replies: []
|
130
130
|
- :author: madethemcry
|
131
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfihi5
|
131
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfihi5
|
132
132
|
:body: |-
|
133
133
|
I love to check other results after submission, it's the zen time after the intense coding time. There is always a tiny thing to learn. Your hash building is great with the use of `group_by` & `transform_values(&:count)`. Also the way you work on the keys with `transform_keys` is much more elegant than my naive solution using `hash.each do |key, value|` and so on.
|
134
134
|
|
135
135
|
I learned that from you today and I will put that knowledge into my AoC bag for the rest of the days. Thank you!
|
136
136
|
:replies:
|
137
137
|
- :author: ignurant
|
138
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfk2cx
|
138
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfk2cx
|
139
139
|
:body: |-
|
140
140
|
Nice! Immediately after posting it I realized “doh! group and count is the same as newer tally” and snuck a tiny edit in. I figured I should spill the beans since you referenced my original note first ;)
|
141
141
|
|
142
142
|
I’m enjoying reading the solutions. Did you see the Rockstar post? Omg search for it. Rofl.
|
143
143
|
:replies:
|
144
144
|
- :author: madethemcry
|
145
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnflb8r
|
145
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnflb8r
|
146
146
|
:body: I used `tally` myself for day 5 and I did not realize that I just referenced it on your code :D I think it's a great change, thanks for noting it. I have seen the rockstar solution. Everytime someone post a rockstar solution I can't believe how naturally it reads.
|
147
147
|
:replies: []
|
148
148
|
- :author: flwyd
|
149
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfqfkg
|
149
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfqfkg
|
150
150
|
:body: |-
|
151
151
|
> I was going to use arrays, but it was easier for me to grok a fish resetting it's cycle with a hash.
|
152
152
|
|
153
153
|
If you don't care about iteration order, an array is really just a hash with more limitations.
|
154
154
|
:replies: []
|
155
155
|
- :author: snowe2010
|
156
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnoklbr
|
156
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnoklbr
|
157
157
|
:body: nice. you can also get rid of the compact by using `.delete(-1)` instead of `fish[-1] = nil`.
|
158
158
|
:replies:
|
159
159
|
- :author: ignurant
|
160
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnrdxso
|
160
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnrdxso
|
161
161
|
:body: Ugh! I know it! Haha. It was a point of personal contention while writing actually. Because without that, there’s a teeny tiny memory leak. I felt unwell that for every tick, we were accumulating an extra key for literally no good reason. But for some reason, I had I ssues trying to delete that key. I might have had slight differences in my versions before I arrived at this solution that was causing an error… I don’t know. Sigh! Good catch, it was later bothering me that I submitted such negligence but I’d since moved on. I was hoping only a few clever folks would notice!!!
|
162
162
|
:replies:
|
163
163
|
- :author: snowe2010
|
164
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnsfj4m
|
164
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnsfj4m
|
165
165
|
:body: Nah, I'm in no way clever. I had too much trouble with this problem and literally had to read over your solution several times and then my solution ended up just being yours with `.delete` instead of the nil/compact. I was just bothered by the nil because I was printing out the full array on each step and so when I was trying to debug through your code to understand it it got in the way. Thanks for the awesome solution! Wish I could have figured it out myself. :(
|
166
166
|
:replies: []
|
167
167
|
- :author: MuumiJumala
|
168
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfdhsi
|
168
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfdhsi
|
169
169
|
:body: |-
|
170
170
|
Ruby (77 bytes)
|
171
171
|
|
@@ -177,11 +177,11 @@
|
|
177
177
|
```
|
178
178
|
:replies:
|
179
179
|
- :author: madethemcry
|
180
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfj0td
|
180
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfj0td
|
181
181
|
:body: "I expected to read some artificially code golfed solution. It's quote the opposite. That's so good using modulo. Even though it's small you can perfectly follow it. Great solution \U0001F44D"
|
182
182
|
:replies: []
|
183
183
|
- :author: kyletbyrne
|
184
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hniff5d
|
184
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hniff5d
|
185
185
|
:body: |-
|
186
186
|
A very ruby'ish **Ruby** solution
|
187
187
|
|
@@ -200,7 +200,7 @@
|
|
200
200
|
```
|
201
201
|
:replies: []
|
202
202
|
- :author: ni3t
|
203
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfju54
|
203
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfju54
|
204
204
|
:body: |-
|
205
205
|
### Ruby
|
206
206
|
|
@@ -219,14 +219,14 @@
|
|
219
219
|
```
|
220
220
|
:replies: []
|
221
221
|
- :author: rlafranchi
|
222
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnhbckm
|
222
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnhbckm
|
223
223
|
:body: |-
|
224
224
|
simple Ruby solution..
|
225
225
|
|
226
226
|
https://topaz.github.io/paste/#XQAAAQD/AAAAAAAAAAA0m4poOBCMftdkRQiciXYGFBdGwmQTxpvYqfn/WzgEEWBwIB+mywy2GikxWQ4hPwmjdCcHX1IbJZx2dDAedN9rOh3RcGbDK3JV7hBronMBGj6VS2QHkwELEyBhisBpJmh63t+UIgOPjvVWUdqj6n+VXoSvxc4EshLFWaAoi4O7pSaXXHJYJf8C1pdmYm6VyR8mApbC1gvnlakU/hi35R8wLcYnd5hJcTdY+EVl40jafvwSIEA=
|
227
227
|
:replies: []
|
228
228
|
- :author: BluFoot
|
229
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfc1ob
|
229
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfc1ob
|
230
230
|
:body: |-
|
231
231
|
**Ruby 81 bytes**
|
232
232
|
|
@@ -239,11 +239,11 @@
|
|
239
239
|
```
|
240
240
|
:replies:
|
241
241
|
- :author: k_duder
|
242
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfe0hc
|
242
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfe0hc
|
243
243
|
:body: h=eval"[#{$\<.read}].tally"
|
244
244
|
:replies: []
|
245
245
|
- :author: marshalofthemark
|
246
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfeksm
|
246
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfeksm
|
247
247
|
:body: |-
|
248
248
|
**Ruby**
|
249
249
|
|
@@ -262,7 +262,7 @@
|
|
262
262
|
```
|
263
263
|
:replies: []
|
264
264
|
- :author: eyelligator
|
265
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfhxfg
|
265
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfhxfg
|
266
266
|
:body: |-
|
267
267
|
Ended up reworking my naive solution for #1, as most seem to have (I took a heinous detour in attempting to find the solution via determining the exponential formula.. Let's not talk about it)
|
268
268
|
|
@@ -282,7 +282,7 @@
|
|
282
282
|
```
|
283
283
|
:replies: []
|
284
284
|
- :author: frontpageminus
|
285
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfahie
|
285
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfahie
|
286
286
|
:body: |-
|
287
287
|
Ruby 131/165
|
288
288
|
|
@@ -291,7 +291,7 @@
|
|
291
291
|
[much faster part 2](https://topaz.github.io/paste/#XQAAAQBnAQAAAAAAAAA4GUqqcrz6bt9iIGDOK/hD3S64xog4ceY/1Rc5ZPlx7rhfLTkxZEAdpPXH1UHUQfx+egiNd7bquQzL6rB8Npd2bIF44LQr36hhhoHSmllvHtA76gTdpWEKXcAW6Cd7m/EINSlU/huxuPXtZWMUsqqoIoFSpb9YSuoi7JqZzW3EpcqMxwSTAwAdR8wCUR6d2Q5kTlmjiGZ7QQjDj14u7Yn0y3XN5t/WlY8L/iClL4fKnBCTirZpbIMS0HaBjcWBW8M9BwhyRj/9gfKu)
|
292
292
|
:replies: []
|
293
293
|
- :author: gurgeous
|
294
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfbywy
|
294
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfbywy
|
295
295
|
:body: |-
|
296
296
|
Ruby, after some code golf
|
297
297
|
|
@@ -309,18 +309,18 @@
|
|
309
309
|
```
|
310
310
|
:replies:
|
311
311
|
- :author: BluFoot
|
312
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfc7id
|
312
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfc7id
|
313
313
|
:body: |-
|
314
314
|
you can do `256.times` instead of `1.upto(256)` ~~and for reading the input you can do data = data.split(',').map(&:to\_i).tally~~
|
315
315
|
|
316
316
|
edit: nvm your data parsing is different from mine
|
317
317
|
:replies:
|
318
318
|
- :author: gurgeous
|
319
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfgrqa
|
319
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfgrqa
|
320
320
|
:body: I had a tally version (hash) but eventually switched to an array so I could grab a slice later. There are many nice Ruby solutions I think :)
|
321
321
|
:replies: []
|
322
322
|
- :author: p_tseng
|
323
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfffvr
|
323
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfffvr
|
324
324
|
:body: |-
|
325
325
|
### Ruby
|
326
326
|
|
@@ -353,11 +353,11 @@
|
|
353
353
|
```
|
354
354
|
:replies: []
|
355
355
|
- :author: madethemcry
|
356
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfg9it
|
356
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfg9it
|
357
357
|
:body: "# RUBY\n\n[georgiee/advent-of-code-2021/day-06 (GitHub)](https://github.com/georgiee/advent-of-code-2021/tree/main/day-06)\n\n# Notes\n\nI completed part 1 in under 20min. I had directly the idea to use an `Enumerator` which internally uses `inject` to grow the array of numbers. That worked flawless and I almost wondered, that's too easy. Then came part 2 around the corner and my solution did not scale well \U0001F605 I could have expected this seeing so high numbers. Because in my solution this means growing an array beyond the capabilities of my laptop. That was a great trap!\n\nLuckily I directly had another solution in mind: A hash to act as the dictionary for the amount of fish being alive with a specific life count. I struggled a little bit twisting my logic now but after another 30min I was done. The awesome thing is how fast it runs now. Where it hung before I have now the following benchmark results:\n\n```ruby\n 0.003253 0.000116 0.003369 ( 0.003424)\n```\n\nThis means my script runs in ~3.5 ms in realtime for part 2 \U0001F918\n\nIn addition the enumerator interface works so well for this in terms of readability. I can specify a day and then I get the result. The only thing I have to do is to take the last hash and the sum the values.\n\n```ruby\nfishlife.take(256).last.values.sum\n```\n\nDone ✅\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\ninitial_state = input.clone\ninitial_life = initial_state.inject(Hash.new(0)) { |hash, value| hash[value] += 1; hash }\n\n# This was growing an array for part 1 which is super inefficient.\n# I could have expected this for day 6 \U0001F605\n# Hash is super performant\nfishlife = Enumerator.new do |yielder|\n last_day = initial_life.clone\n\n loop do\n next_life = Hash.new(0)\n last_day.each do |remaining_life, fish_count|\n if remaining_life == 0\n next_life[8] += fish_count # spawn\n next_life[6] += fish_count # reset\n else\n next_life[remaining_life - 1] += fish_count\n end\n end\n\n last_day = next_life\n yielder << next_life\n end\nend\n\n# 0.003041 0.000074 0.003115 ( 0.003129)\nputs Benchmark.measure {\n puts \"Result it #{fishlife.take(256).last.values.sum}\"\n}\n```"
|
358
358
|
:replies: []
|
359
359
|
- :author: shandley256
|
360
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfpr50
|
360
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnfpr50
|
361
361
|
:body: |-
|
362
362
|
Solution in Ruby. Runs in under 1/10th of a second.
|
363
363
|
|
@@ -389,7 +389,7 @@
|
|
389
389
|
```
|
390
390
|
:replies: []
|
391
391
|
- :author: cionescu
|
392
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hng18cd
|
392
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hng18cd
|
393
393
|
:body: |-
|
394
394
|
# Ruby solution
|
395
395
|
|
@@ -420,7 +420,7 @@
|
|
420
420
|
```
|
421
421
|
:replies: []
|
422
422
|
- :author: icyFur
|
423
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hng1xts
|
423
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hng1xts
|
424
424
|
:body: |-
|
425
425
|
I made a bucket solution in Ruby ([full code](https://getsturdy.com/advent-of-code-2021-uoeIDQk/changes)):
|
426
426
|
|
@@ -450,7 +450,7 @@
|
|
450
450
|
```
|
451
451
|
:replies: []
|
452
452
|
- :author: damyvv
|
453
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hng3w2f
|
453
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hng3w2f
|
454
454
|
:body: |-
|
455
455
|
# Ruby
|
456
456
|
|
@@ -470,7 +470,7 @@
|
|
470
470
|
```
|
471
471
|
:replies: []
|
472
472
|
- :author: BramboraSK
|
473
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnh3osl
|
473
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnh3osl
|
474
474
|
:body: |-
|
475
475
|
Pretty satisfied with my **Ruby** solution today (I started learning it like a week ago)
|
476
476
|
|
@@ -515,7 +515,7 @@
|
|
515
515
|
```
|
516
516
|
:replies: []
|
517
517
|
- :author: 404_denied
|
518
|
-
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnhbh5c
|
518
|
+
:url: https://www.reddit.com/r/adventofcode/comments/r9z49j/2021_day_6_solutions/hnhbh5c
|
519
519
|
:body: |-
|
520
520
|
A straightforward Ruby solution with using recursion & memoization for the second part of the puzzle:
|
521
521
|
|