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: rkachowski
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqshwef
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqshwef
|
4
4
|
:body: |-
|
5
5
|
in ruby, this felt simultaneously wayy too easy and waayy too dirty of a solution. i feel like i'm missing some really elegant iteration trick, but everyone in this thread seems to have the same approach
|
6
6
|
|
@@ -27,7 +27,7 @@
|
|
27
27
|
```
|
28
28
|
:replies:
|
29
29
|
- :author: jschulenklopper
|
30
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqsj6pi
|
30
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqsj6pi
|
31
31
|
:body: |-
|
32
32
|
Here's the iteration trick that I used. (Also, your code would not catch if the index would run out at the other end, so below 0.)
|
33
33
|
|
@@ -47,7 +47,7 @@
|
|
47
47
|
What I like in your solution is that you're passing the proper increment function as a block to `jump()`. Kudos to you.
|
48
48
|
:replies: []
|
49
49
|
- :author: gettalong
|
50
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqt8aci
|
50
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqt8aci
|
51
51
|
:body: |-
|
52
52
|
Here is my 2-line quick and dirty solution for use in IRB:
|
53
53
|
|
@@ -57,7 +57,7 @@
|
|
57
57
|
```
|
58
58
|
:replies: []
|
59
59
|
- :author: OneEyedGammer
|
60
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqshytd
|
60
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqshytd
|
61
61
|
:body: |-
|
62
62
|
My god, I spent almost 10 minutes trying to figure out why my code wasn't working on part 2. Turns out it doesn't want an absolute value.
|
63
63
|
|
@@ -87,15 +87,15 @@
|
|
87
87
|
```
|
88
88
|
:replies:
|
89
89
|
- :author: gbeier
|
90
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqu1ghw
|
90
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqu1ghw
|
91
91
|
:body: I made the exact same mistake. I think "offset" tripped that in my brain.
|
92
92
|
:replies:
|
93
93
|
- :author: OneEyedGammer
|
94
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dquvrb8
|
94
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dquvrb8
|
95
95
|
:body: I don't think we're wrong for thinking that way. From what I've seen from programming challenges it would read that way. Oh well, it didn't take long to long to notice what was wrong.
|
96
96
|
:replies: []
|
97
97
|
- :author: andreesgor
|
98
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqti5pu
|
98
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqti5pu
|
99
99
|
:body: |-
|
100
100
|
Ruby:
|
101
101
|
|
@@ -125,7 +125,7 @@
|
|
125
125
|
```
|
126
126
|
:replies: []
|
127
127
|
- :author: Unihedron
|
128
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqsdne6
|
128
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqsdne6
|
129
129
|
:body: |-
|
130
130
|
Ruby. Huge disappointment! I was running my day4 code instead of my day5 code. I couldn't even count what day it is anymore :)
|
131
131
|
|
@@ -149,7 +149,7 @@
|
|
149
149
|
PS: I've been keeping a [small blog over on github detailing my Aoc adventure so far.](https://github.com/Unihedro/workout/blob/master/adventofcode2017/entry1.md) there will be a short break before I "blog" about day6+ again though
|
150
150
|
:replies:
|
151
151
|
- :author: jschulenklopper
|
152
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqshm9c
|
152
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqshm9c
|
153
153
|
:body: |-
|
154
154
|
Another solution in Ruby. A bit more characters, a bit less magic :-)
|
155
155
|
|
@@ -165,7 +165,7 @@
|
|
165
165
|
```
|
166
166
|
:replies:
|
167
167
|
- :author: Unihedron
|
168
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqshxts
|
168
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqshxts
|
169
169
|
:body: |-
|
170
170
|
Respect! Really tidy code - I wrote mine in a rush :/. Some notes (not sure if it'll be helpful but in case it expands your knowledge):
|
171
171
|
|
@@ -173,11 +173,11 @@
|
|
173
173
|
2. `map!` is a destructive operation which (attempts to) change the original Enumerable as well, it doesn't do much in this case so it can be `map` instead.
|
174
174
|
:replies:
|
175
175
|
- :author: jschulenklopper
|
176
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqsizom
|
176
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqsizom
|
177
177
|
:body: Ha, those were indeed two minor improvements that I made later (updated in the post as well). Looks just like a recent discovery that `.split(" ")` would split on spaces _and_ tabs... just as the default `.split` without argument :-)
|
178
178
|
:replies:
|
179
179
|
- :author: Unihedron
|
180
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqsjhqj
|
180
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hngbn/2017_day_5_solutions/dqsjhqj
|
181
181
|
:body: |-
|
182
182
|
Hello, yes, .split uses $; by default, if $; is nil then it uses whitespace. This means newline characters are also included. As such $\<.read.split will give you all non-space character sequences when the parameter is not specified. The use of this global variable is very similar to how perl implements input parsing.
|
183
183
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: Unihedron
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqu8dku
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqu8dku
|
4
4
|
:body: |-
|
5
5
|
Ruby; I tried guessing what it wanted me to do (fill towards the start and loop back, instead of filling after the index of the unit) and I guessed wrong. :P
|
6
6
|
|
@@ -27,19 +27,19 @@
|
|
27
27
|
```
|
28
28
|
:replies:
|
29
29
|
- :author: nakilon
|
30
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqua8h9
|
30
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqua8h9
|
31
31
|
:body: Excuse me, where is the loop?
|
32
32
|
:replies:
|
33
33
|
- :author: Unihedron
|
34
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqub2k2
|
34
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqub2k2
|
35
35
|
:body: The loop starts at previous counter with the same state to the current counter. `p i` prints the solution for part 1, while `h[s.to_s]` to `i` is the loop, so the size is `p i-h[s.to_s]`
|
36
36
|
:replies:
|
37
37
|
- :author: nakilon
|
38
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dquelrk
|
38
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dquelrk
|
39
39
|
:body: Oops, didn't see the markdown code block had scrollbar...
|
40
40
|
:replies: []
|
41
41
|
- :author: jschulenklopper
|
42
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dquidyd
|
42
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dquidyd
|
43
43
|
:body: |-
|
44
44
|
My solution in Ruby, also using string representation of memory banks as key in a hash, and the cycle count of when that configuration has been seen is stored as value.
|
45
45
|
|
@@ -70,7 +70,7 @@
|
|
70
70
|
```
|
71
71
|
:replies: []
|
72
72
|
- :author: nakilon
|
73
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqu8dry
|
73
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqu8dry
|
74
74
|
:body: |-
|
75
75
|
# Ruby
|
76
76
|
|
@@ -107,18 +107,18 @@
|
|
107
107
|
```
|
108
108
|
:replies:
|
109
109
|
- :author: Unihedron
|
110
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqudd9e
|
110
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqudd9e
|
111
111
|
:body: ~~$/=' ';a=$\<.map &:to\_i to get rid of another char.~~ (\<- I couldn't get it to put a tab character here) `until ... end` can be replaced with modifier syntax `()until ...` to get rid of 2 chars (including whitespace). Also, it doesn't really matter that `m` is initialized to zero for part 2 (end+k - start+k == end-start) so you can delete `,m ,0` and replace the two `m` references with the global variable `$.` which is the "lines read" counter (because we don't use `gets` again)
|
112
112
|
:replies:
|
113
113
|
- :author: nakilon
|
114
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dquek6v
|
114
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dquek6v
|
115
115
|
:body: |-
|
116
116
|
There is some problem with input taken from site -- maybe that some gaps consist of two whitespace characters instead of one so `a` gets parsed incorrectly for me.
|
117
117
|
|
118
118
|
The rest works fine. Thanks! -4 chars
|
119
119
|
:replies: []
|
120
120
|
- :author: dtinth
|
121
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqw138x
|
121
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqw138x
|
122
122
|
:body: |-
|
123
123
|
**Ruby REPL** (irb) solution. The `pbpaste` command must be available in the `$PATH`, and should return the contents in the clipboard (macOS has this command by default).
|
124
124
|
|
@@ -137,7 +137,7 @@
|
|
137
137
|
```
|
138
138
|
:replies: []
|
139
139
|
- :author: doromin
|
140
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqudcpy
|
140
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqudcpy
|
141
141
|
:body: |-
|
142
142
|
**Ruby** simply using mem-string(join) instead of array of mem-arrays as comparison made it fast enough.
|
143
143
|
|
@@ -177,14 +177,14 @@
|
|
177
177
|
```
|
178
178
|
:replies:
|
179
179
|
- :author: jschulenklopper
|
180
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqui874
|
180
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqui874
|
181
181
|
:body: |-
|
182
182
|
Question: would your `data.join` not be fallible for cases in which the string representation of two different arrays is equal? As in: `[1,11,0,22,2].join == [11,1,0,2,22].join` which is `true`, but the arrays clearly aren't.
|
183
183
|
|
184
184
|
I think you got lucky that this case didn't appear with your input :-) A `data.join(",")` would prevent this from occurring.
|
185
185
|
:replies: []
|
186
186
|
- :author: disclosure5
|
187
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqui8ho
|
187
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqui8ho
|
188
188
|
:body: |-
|
189
189
|
Rather than paste another boring Ruby solution, this is the sort of workload where jruby shines. Have a benchmark. Even though this horrible test included the significant warm up time, which is about six seconds on this machine.
|
190
190
|
|
@@ -196,7 +196,7 @@
|
|
196
196
|
```
|
197
197
|
:replies:
|
198
198
|
- :author: maxerickson
|
199
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqumy44
|
199
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqumy44
|
200
200
|
:body: |-
|
201
201
|
Looks like checking whether the current arrangement has already occurred is really costly there. My solution is similar to the Python solutions posted already, uses sets to check for the repeat (my computer is ancient):
|
202
202
|
|
@@ -206,17 +206,17 @@
|
|
206
206
|
```
|
207
207
|
:replies:
|
208
208
|
- :author: nakilon
|
209
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqv10ll
|
209
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqv10ll
|
210
210
|
:body: I suppose he's putting arrangements to Array, not Hash. That costs him a lot but he's free of collision unlike of your solution.
|
211
211
|
:replies: []
|
212
212
|
- :author: nakilon
|
213
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqv0wdf
|
213
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqv0wdf
|
214
214
|
:body: |-
|
215
215
|
I've got 0.090s and 0.170s
|
216
216
|
|
217
217
|
Is my MRI broken?
|
218
218
|
:replies:
|
219
219
|
- :author: disclosure5
|
220
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqv90m8
|
220
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7hvtoq/2017_day_6_solutions/dqv90m8
|
221
221
|
:body: I'm going to guess your solution is a lot more performant!
|
222
222
|
:replies: []
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: Unihedron
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqw1an1
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqw1an1
|
4
4
|
:body: |-
|
5
5
|
Ruby; kinda late, had to rewrite a lot. I assumed the puzzle was "validate heights" (and a wrong one was provided), not "ensure balancing", based on the highlighted text. Even after I rewrote my code, it showed 2 wrong sectors, which worried me hugely. It took a long time for me to realize that I should manually dig through the input for the disc to change. Fun riddle!
|
6
6
|
|
@@ -32,18 +32,18 @@
|
|
32
32
|
```
|
33
33
|
:replies:
|
34
34
|
- :author: topaz2078
|
35
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqw1kdy
|
35
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqw1kdy
|
36
36
|
:body: |-
|
37
37
|
> Also I think we're reaching the point where forfeiting readability for speed is starting to become a liability.
|
38
38
|
|
39
39
|
**_yes_**
|
40
40
|
:replies: []
|
41
41
|
- :author: LeCrushinator
|
42
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqxs2mv
|
42
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqxs2mv
|
43
43
|
:body: This looks similar to when I let my 4 year old pretend they're typing something on the keyboard. I've been programming for years and this still looks like greek to me.
|
44
44
|
:replies: []
|
45
45
|
- :author: arachnist
|
46
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqw96y5
|
46
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqw96y5
|
47
47
|
:body: |-
|
48
48
|
Went through my pry and zsh history, and cleaned up the ruby solution i came up with in the morning
|
49
49
|
|
@@ -130,7 +130,7 @@
|
|
130
130
|
```
|
131
131
|
:replies: []
|
132
132
|
- :author: dtinth
|
133
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqw10dq
|
133
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7i44pg/2017_day_7_solutions/dqw10dq
|
134
134
|
:body: |-
|
135
135
|
**Ruby REPL** (irb) solution. The `pbpaste` command must be available in the `$PATH`, and should return the contents in the clipboard (macOS has this command by default).
|
136
136
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: _jonah
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxtsqy
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxtsqy
|
4
4
|
:body: |-
|
5
5
|
# Vim + Ruby
|
6
6
|
|
@@ -58,19 +58,19 @@
|
|
58
58
|
Part 2 is similar
|
59
59
|
:replies:
|
60
60
|
- :author: fwilson42
|
61
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxu6f5
|
61
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxu6f5
|
62
62
|
:body: I wonder if you could've defined a `method_missing` or something similar to get rid of the initializers. Either way, vim-based solutions are always impressive... nice!
|
63
63
|
:replies: []
|
64
64
|
- :author: "[deleted]"
|
65
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy6qde
|
65
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy6qde
|
66
66
|
:body: I like these vim solutions a lot, and I really enjoy the work you put into describing them :) cool!
|
67
67
|
:replies: []
|
68
68
|
- :author: ramendik
|
69
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqz9xmm
|
69
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqz9xmm
|
70
70
|
:body: Looks nice, but what if the if clause contains a register that is never modified and thus, in your solution, apparently never initialized?
|
71
71
|
:replies: []
|
72
72
|
- :author: p_tseng
|
73
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy1qbs
|
73
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy1qbs
|
74
74
|
:body: |-
|
75
75
|
Ruby does this thing like SmallTalk where you send objects messages, and the objects respond. It so happens that I can give an object a message saying `>, 4` and it will tell me whether it is greater than 4. And so it goes for the other operators used as well.
|
76
76
|
|
@@ -94,15 +94,15 @@
|
|
94
94
|
```
|
95
95
|
:replies:
|
96
96
|
- :author: hxka
|
97
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy85h0
|
97
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy85h0
|
98
98
|
:body: Um, doesn't `send` simply call an object's method by its name and what you do is possible because in Ruby `a op b` is sugar for `a.op(b)`?
|
99
99
|
:replies:
|
100
100
|
- :author: p_tseng
|
101
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqyiv5q
|
101
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqyiv5q
|
102
102
|
:body: Yes, exactly! As you explained, send has broader consequences than I managed to impart with my explanation.
|
103
103
|
:replies: []
|
104
104
|
- :author: Unihedron
|
105
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxtdjy
|
105
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxtdjy
|
106
106
|
:body: |-
|
107
107
|
Ruby. I missed the alarm and woke up exactly 2 minutes before this day opens.
|
108
108
|
|
@@ -123,7 +123,7 @@
|
|
123
123
|
```
|
124
124
|
:replies:
|
125
125
|
- :author: jschulenklopper
|
126
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqz1rkb
|
126
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqz1rkb
|
127
127
|
:body: |-
|
128
128
|
Same idea here, a bit more readable:
|
129
129
|
|
@@ -149,7 +149,7 @@
|
|
149
149
|
```
|
150
150
|
:replies: []
|
151
151
|
- :author: dtinth
|
152
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxt964
|
152
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxt964
|
153
153
|
:body: |-
|
154
154
|
# Ruby
|
155
155
|
|
@@ -166,7 +166,7 @@
|
|
166
166
|
```
|
167
167
|
:replies: []
|
168
168
|
- :author: eregontp
|
169
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy41zl
|
169
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy41zl
|
170
170
|
:body: |-
|
171
171
|
Metaprogramming is the better eval! Looks like this one is made for Ruby as operators match nicely:
|
172
172
|
|
@@ -184,7 +184,7 @@
|
|
184
184
|
```
|
185
185
|
:replies: []
|
186
186
|
- :author: reacher
|
187
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxtd8p
|
187
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxtd8p
|
188
188
|
:body: |-
|
189
189
|
**Ruby**
|
190
190
|
|
@@ -229,7 +229,7 @@
|
|
229
229
|
```
|
230
230
|
:replies: []
|
231
231
|
- :author: arachnist
|
232
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxx4d3
|
232
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxx4d3
|
233
233
|
:body: |-
|
234
234
|
I couldn't get instance\_variable\_(get|set) to work as i wanted, so I couldn't feed input directly into ruby.
|
235
235
|
|
@@ -253,7 +253,7 @@
|
|
253
253
|
```
|
254
254
|
:replies: []
|
255
255
|
- :author: rkachowski
|
256
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy19o0
|
256
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy19o0
|
257
257
|
:body: |-
|
258
258
|
ruby! 9 lines!
|
259
259
|
|
@@ -272,7 +272,7 @@
|
|
272
272
|
```
|
273
273
|
:replies: []
|
274
274
|
- :author: el_daniero
|
275
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy1dvf
|
275
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqy1dvf
|
276
276
|
:body: |-
|
277
277
|
# Ruby: String substitution and eval
|
278
278
|
|
@@ -312,7 +312,7 @@
|
|
312
312
|
https://github.com/daniero/code-challenges/blob/master/aoc2017/ruby/08.rb
|
313
313
|
:replies: []
|
314
314
|
- :author: Sharparam
|
315
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqyl12l
|
315
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqyl12l
|
316
316
|
:body: |-
|
317
317
|
[**Ruby**](https://github.com/Sharparam/advent-of-code/tree/master/2017): Using `method_missing` and `eval` without tampering or matching on the input data.
|
318
318
|
|
@@ -337,14 +337,14 @@
|
|
337
337
|
```
|
338
338
|
:replies:
|
339
339
|
- :author: patrickdavey
|
340
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqyrhce
|
340
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqyrhce
|
341
341
|
:body: |-
|
342
342
|
Thanks for posting this. I do write ruby for a day job, but, I hardly ever mess around with method\_missing and friends. Really interesting to see how that all works, how it's smart enough to pass the args along to your `dec` and `inc` methods etc.
|
343
343
|
|
344
344
|
Really neat! thanks for sharing.
|
345
345
|
:replies: []
|
346
346
|
- :author: rhardih
|
347
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxyq5h
|
347
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7icnff/2017_day_8_solutions/dqxyq5h
|
348
348
|
:body: |-
|
349
349
|
Ruby, with eval injecting the condition:
|
350
350
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: Unihedron
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqziwer
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqziwer
|
4
4
|
:body: |-
|
5
5
|
Ruby. Tried writing a regex hack for part 1 to avoid writing a stack engine, didn't work out. Vastly disappointed by the amount of failures and ended up being penalized heavily in terms of waiting. Part 2 was shockingly easy though, feels like it could had been swapped with part 1.
|
6
6
|
|
@@ -23,7 +23,7 @@
|
|
23
23
|
```
|
24
24
|
:replies:
|
25
25
|
- :author: nakilon
|
26
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzj539
|
26
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzj539
|
27
27
|
:body: |-
|
28
28
|
Wow, didn't expect solution with gsub would be that short. Here is a straight-forward state machine:
|
29
29
|
|
@@ -60,7 +60,7 @@
|
|
60
60
|
```
|
61
61
|
:replies: []
|
62
62
|
- :author: dtinth
|
63
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzi2be
|
63
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzi2be
|
64
64
|
:body: |-
|
65
65
|
# Ruby one-liner (16th, 15th)
|
66
66
|
|
@@ -85,11 +85,11 @@
|
|
85
85
|
- `gc` garbage count
|
86
86
|
:replies:
|
87
87
|
- :author: nakilon
|
88
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzj0zn
|
88
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzj0zn
|
89
89
|
:body: Your definition of the term "one-liner" is wrong.
|
90
90
|
:replies: []
|
91
91
|
- :author: yjerem
|
92
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzjj37
|
92
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzjj37
|
93
93
|
:body: |-
|
94
94
|
Ruby with regex
|
95
95
|
|
@@ -114,7 +114,7 @@
|
|
114
114
|
```
|
115
115
|
:replies: []
|
116
116
|
- :author: rnd4g
|
117
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzjrdz
|
117
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dqzjrdz
|
118
118
|
:body: |-
|
119
119
|
Ruby. Figured out that you can drop everything that doesn't matter and eval the rest. Ugly code warning.
|
120
120
|
|
@@ -149,7 +149,7 @@
|
|
149
149
|
```
|
150
150
|
:replies: []
|
151
151
|
- :author: rkachowski
|
152
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dr04rmz
|
152
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7iksqc/2017_day_9_solutions/dr04rmz
|
153
153
|
:body: |-
|
154
154
|
ruby, i had to shake off the hangover for this one. i never thought about just gsub-ing out the exclamation mark and every next character.. i iterated over the chars and moved 2 steps forward when one was found... i'll leave it in though as a testament to try harder
|
155
155
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: p_tseng
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr10wbf
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr10wbf
|
4
4
|
:body: |-
|
5
5
|
Part 1 went well. Thanks to language I chose (Ruby), it is easy to code the "reverse these N elements" without error. Since I didn't want to deal with the wrap-around, I just always rotate the array so that I'm reversing the **first** N elements, and then rotate the array back when I'm done. This can be done in the various languages that allow assigning an array A1 into a subarray of another array A2, modifying multiple elements of A2 at once. For another example language, Python will do this too with `l[0:5] = reversed(l[0:5])`
|
6
6
|
|
@@ -35,15 +35,15 @@
|
|
35
35
|
```
|
36
36
|
:replies:
|
37
37
|
- :author: KnorbenKnutsen
|
38
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr1bld9
|
38
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr1bld9
|
39
39
|
:body: Did the same thing in Python, kept the list in a deque that I rotated `-(current_position + skip_steps) % len(my_deque)` every time. Kinda neat IMO.
|
40
40
|
:replies: []
|
41
41
|
- :author: hpzr24w
|
42
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr1f30q
|
42
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr1f30q
|
43
43
|
:body: Yes, I like that idea of doing the rotation. Ended up rolling my own C++ `reverse()` rather than being able to use the Standard Library.
|
44
44
|
:replies: []
|
45
45
|
- :author: dtinth
|
46
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr108bt
|
46
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr108bt
|
47
47
|
:body: |-
|
48
48
|
# irb (Ruby REPL) (41st, 16th)
|
49
49
|
|
@@ -58,11 +58,11 @@
|
|
58
58
|
```
|
59
59
|
:replies:
|
60
60
|
- :author: Unihedron
|
61
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr10yki
|
61
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr10yki
|
62
62
|
:body: Ah, .each_slice! that was the library method I was missing... I've been trying to use `(0...256).group_by{|x|x/16}.map{|x,y|l[x,16].inject &:^}` and it was not giving me the right thing.
|
63
63
|
:replies: []
|
64
64
|
- :author: Unihedron
|
65
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr113ne
|
65
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr113ne
|
66
66
|
:body: |-
|
67
67
|
Ruby; Trigger warning: state approaching unsalvageable, not even I know what's happening here. I spent way too much time debugging because I used the wrong method to chop up the length-16 blocks.
|
68
68
|
|
@@ -95,7 +95,7 @@
|
|
95
95
|
```
|
96
96
|
:replies: []
|
97
97
|
- :author: mrstickman
|
98
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr12r55
|
98
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr12r55
|
99
99
|
:body: |-
|
100
100
|
Ruby 406/677: https://pastebin.com/qPtLqvzB
|
101
101
|
|
@@ -104,7 +104,7 @@
|
|
104
104
|
- According to my stats page, this was some of my slowest work (counting only time spent actually working on the problem and not, say, sleeping or having a life outside of this), but I ranked higher than I ever have. This one's gonna be a weed-out problem for the masses.
|
105
105
|
:replies: []
|
106
106
|
- :author: rkachowski
|
107
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr18nn4
|
107
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr18nn4
|
108
108
|
:body: |-
|
109
109
|
ruby! this is the first time i've had problems with understanding the task that weren't due to reading the task too quickly. i had to stare at the part 2 task description for around 30 minutes before i could work out what was actually expected
|
110
110
|
|
@@ -157,7 +157,7 @@
|
|
157
157
|
```
|
158
158
|
:replies: []
|
159
159
|
- :author: skarlso
|
160
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr202kk
|
160
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7irzg5/2017_day_10_solutions/dr202kk
|
161
161
|
:body: |-
|
162
162
|
I'm actually happy with this _Ruby_ solution.
|
163
163
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: Unihedron
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr4fte4
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr4fte4
|
4
4
|
:body: |-
|
5
5
|
Ruby, silver 17 / gold 29
|
6
6
|
|
@@ -29,15 +29,15 @@
|
|
29
29
|
```
|
30
30
|
:replies:
|
31
31
|
- :author: Grimnur87
|
32
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr4r78n
|
32
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr4r78n
|
33
33
|
:body: Yes, I messed about with 10.times, 20.times etc myself until deciding that an until loop would be more foolproof.
|
34
34
|
:replies:
|
35
35
|
- :author: Unihedron
|
36
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr4uc90
|
36
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr4uc90
|
37
37
|
:body: What we need is a graph library like how python has networkx :)
|
38
38
|
:replies: []
|
39
39
|
- :author: el_daniero
|
40
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr5frta
|
40
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr5frta
|
41
41
|
:body: |-
|
42
42
|
Line 3: No need to split each line twice, just `scan` it for number-looking things:
|
43
43
|
|
@@ -46,7 +46,7 @@
|
|
46
46
|
```
|
47
47
|
:replies: []
|
48
48
|
- :author: rkachowski
|
49
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr4ojpx
|
49
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr4ojpx
|
50
50
|
:body: |-
|
51
51
|
ruby, in some of the least idiomatic ruby possible!
|
52
52
|
|
@@ -85,7 +85,7 @@
|
|
85
85
|
```
|
86
86
|
:replies: []
|
87
87
|
- :author: el_daniero
|
88
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr5g0bl
|
88
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7j89tr/2017_day_12_solutions/dr5g0bl
|
89
89
|
:body: |-
|
90
90
|
# Ruby
|
91
91
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: p_tseng
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6ftpy
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6ftpy
|
4
4
|
:body: |-
|
5
5
|
After completely failing to get on the leaderboard since my part 2 code ran too slow, it's time to make it faster. It's too inefficient to iterate each possible starting time one by one!
|
6
6
|
|
@@ -77,7 +77,7 @@
|
|
77
77
|
```
|
78
78
|
:replies:
|
79
79
|
- :author: sim642
|
80
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6lufv
|
80
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6lufv
|
81
81
|
:body: |-
|
82
82
|
Took me a while to think through how you're calculating this, especially not being familiar with Ruby syntax. Here's what I managed deduce:
|
83
83
|
|
@@ -90,22 +90,22 @@
|
|
90
90
|
I have to admit, it is pretty clever but from a mathematical point of view, not too general. The speedup only comes in the case where there are periods that forbid all but one value, hopefully multiple such to get a real big congruence at the end. I wonder if this is the case for the AoC inputs because I'm sure in general one could construct a set of depths and ranges that don't do that and maybe always leave two possible values left, etc. The optimization doesn't help in such case as is but I suppose it could be extended to still be smart enough to only consider such two cases separately and continue the reduction recursively or something. This however still sounds like it can be exponential in general if all periods leave multiple possible remainders.
|
91
91
|
:replies:
|
92
92
|
- :author: p_tseng
|
93
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6o0a2
|
93
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6o0a2
|
94
94
|
:body: |-
|
95
95
|
Yup, you've got it, both what I've done and the weaknesses of it. Although it was true for my input that there was only one period that allowed \> 1 value, I can't speak for everyone else's inputs. So I'm guilty of specialising a bit.
|
96
96
|
|
97
97
|
Prompted by your idea I decided to write the code that would try to keep track of multiple possible values (https://github.com/petertseng/adventofcode-rb-2017/tree/day13\_multi), but you are right that it's exponential because the number of possible solutions we need to decide between is the product of the numbers of values allowed by each period.
|
98
98
|
:replies: []
|
99
99
|
- :author: thomastc
|
100
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6nne8
|
100
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6nne8
|
101
101
|
:body: 'Thanks for the summary. This is the direction I was thinking about while my brute force solution was running. It matches my intuition: because we''re looking for something that''s _not_ equal mod something, the CRT is of limited use, and the best we can do is limit the search space a bit.'
|
102
102
|
:replies: []
|
103
103
|
- :author: pak21
|
104
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr7jet2
|
104
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr7jet2
|
105
105
|
:body: Certainly my input has a very similar set of results (must be congruent to 967380 modulo 1441440, must be one of 15 values modulo 34), even to the detail where the two missing values modulo 34 are 967380 and 967380 + 1441440, thus also giving me a solution of the form n + 2 \* 1441440.
|
106
106
|
:replies: []
|
107
107
|
- :author: Unihedron
|
108
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6bw7a
|
108
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7jgyrt/2017_day_13_solutions/dr6bw7a
|
109
109
|
:body: |-
|
110
110
|
Ruby; A good day! Even though I screwed up by doing `(x+1)%(correct base)` and had to fix the +1 (wrong intuition), I still solved both parts quickly enough to be on top 20 for both.
|
111
111
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: Unihedron
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/7jpelc/2017_day_14_solutions/dr8fdsd
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/7jpelc/2017_day_14_solutions/dr8fdsd
|
4
4
|
:body: |-
|
5
5
|
Overslept today, non-competing solution. Nice to get to do this in a relaxed manner for once! ^^ Fun!
|
6
6
|
|