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,41 +1,41 @@
|
|
1
1
|
---
|
2
2
|
- :author: apollo701
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kdcicgh
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kdcicgh
|
4
4
|
:body: |-
|
5
5
|
Took an OOP approach with tests
|
6
6
|
|
7
7
|
https://github.com/JasonDorn/advent-of-code/tree/master/day1-trebuchet
|
8
8
|
:replies: []
|
9
9
|
- :author: wdomburg
|
10
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc9npbc
|
10
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc9npbc
|
11
11
|
:body: |-
|
12
12
|
Not sure whether to be proud or ashamed of this solution.
|
13
13
|
|
14
14
|
> ruby -e "require 'strscan';d={'one'=\>'1','two'=\>'2','three'=\>'3','four'=\>'4','five'=\>'5','six'=\>'6','seven'=\>'7','eight'=\>'8','nine'=\>'9','1'=\>'1','2'=\>'2','3'=\>'3','4'=\>'4','5'=\>'5','6'=\>'6','7'=\>'7','8'=\>'8','9'=\>'9'};re=Regexp.union(d.keys);p ARGF.each.map{|l|ss=StringScanner.new(l);(0..l.length).inject([]){|o,p| ss.pos=p;ss.scan(re)&&o\<\<d[ss.matched];o}.values\_at(0,-1).join.to\_i}.inject(:+)" day01.dat
|
15
15
|
:replies:
|
16
16
|
- :author: wdomburg
|
17
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kcabi8h
|
17
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kcabi8h
|
18
18
|
:body: |-
|
19
19
|
It annoyed me I couldn't fit my solution into a tweet, even without the require statement, so I made it a bit smaller
|
20
20
|
|
21
21
|
> require 'strscan';n=(1..9).map{|s|s.to\_s};d=(n+%w{one two three four five six seven eight nine}).zip(n\*2).to\_h;r=Regexp.union(d.keys);p ARGF.each.map{|l|s=StringScanner.new(l);l.size.times.filter\_map{|i|s.pos=i;d[s.scan(r)]}.values\_at(0,-1).join.to\_i}.inject(:+)
|
22
22
|
:replies: []
|
23
23
|
- :author: wdomburg
|
24
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc9pbre
|
24
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc9pbre
|
25
25
|
:body: |-
|
26
26
|
Just realized I could have cut about 259 characters from my solution by populating the hash like this:
|
27
27
|
|
28
28
|
d=Hash[\*%w{one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8 nine 9 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}]
|
29
29
|
:replies:
|
30
30
|
- :author: wdomburg
|
31
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc9xecd
|
31
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc9xecd
|
32
32
|
:body: |-
|
33
33
|
Okay, down to 267 characters, including the requires.
|
34
34
|
|
35
35
|
ruby -e "require 'strscan';n=(1..9).map{|s|s.to\_s};d=(n+%w{one two three four five six seven eight nine}).zip(n\*2).to\_h;re=Regexp.union(d.keys);p ARGF.each.map{|l|ss=StringScanner.new(l);l.size.times.map{|i|ss.pos=i;d[ss.scan(re)]}.compact.values\_at(0,-1).join.to\_i}.inject(:+)" day01.dat
|
36
36
|
:replies:
|
37
37
|
- :author: RichGuk
|
38
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kg6rsmn
|
38
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kg6rsmn
|
39
39
|
:body: |-
|
40
40
|
I like a bit of Ruby golf.
|
41
41
|
|
@@ -46,7 +46,7 @@
|
|
46
46
|
188 :)
|
47
47
|
:replies:
|
48
48
|
- :author: wdomburg
|
49
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kghmn1r
|
49
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kghmn1r
|
50
50
|
:body: |-
|
51
51
|
> d=['one','two','three','four','five','six','seven','eight','nine'];p ARGF.readlines.map{|l|l.scan(/\d|#{d.join('|')}/).values\_at(0,-1).map{|v|Integer(v) rescue d.index(v)+1}.join.to\_i}.sum
|
52
52
|
|
@@ -67,7 +67,7 @@
|
|
67
67
|
> require 'strscan';d=%w{\d one two three four five six seven eight nine};p $\<.map{|l|ss=StringScanner.new(l);(0..l.size).map{|p|ss.pos=p;ss.scan(/#{d.join('|')}/)&&(m=ss.matched;d.index(m)||m)}.compact.values\_at(0,-1).join.to\_i}.sum
|
68
68
|
:replies:
|
69
69
|
- :author: azzal07
|
70
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/khzrfrs
|
70
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/khzrfrs
|
71
71
|
:body: |-
|
72
72
|
You can also replace `arr.map{fun}.sum` with just `arr.sum{fun}`
|
73
73
|
|
@@ -79,11 +79,11 @@
|
|
79
79
|
```
|
80
80
|
:replies:
|
81
81
|
- :author: wdomburg
|
82
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/ki4l5o3
|
82
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/ki4l5o3
|
83
83
|
:body: Oh! I should have thought to look and see if there was something like that. Thanks!
|
84
84
|
:replies: []
|
85
85
|
- :author: Sharparam
|
86
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbiptap
|
86
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbiptap
|
87
87
|
:body: |-
|
88
88
|
Using the lookahead trick to get overlapping matches with regex.
|
89
89
|
|
@@ -112,11 +112,11 @@
|
|
112
112
|
([GitHub link](https://github.com/Sharparam/advent-of-code/blob/main/src/2023/01/solve.rb))
|
113
113
|
:replies:
|
114
114
|
- :author: dznqbit
|
115
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbiqt98
|
115
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbiqt98
|
116
116
|
:body: Super clean, nice trick with the lookahead
|
117
117
|
:replies: []
|
118
118
|
- :author: spr00ge
|
119
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbj5yhs
|
119
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbj5yhs
|
120
120
|
:body: |-
|
121
121
|
I searched for an overlapping solution for a while and could not find anything. Can you explain your solution a bit more in detail?
|
122
122
|
|
@@ -129,7 +129,7 @@
|
|
129
129
|
```
|
130
130
|
:replies:
|
131
131
|
- :author: Sharparam
|
132
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbjv1t1
|
132
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbjv1t1
|
133
133
|
:body: |-
|
134
134
|
The lookahead is a bit of a hack but it allows for catching the overlaps since it will check the lookahead part (`(?=(\d|...))`) without consuming the string (since the main part of the regex (outside the lookahead) is empty which matches everything/anything).
|
135
135
|
|
@@ -138,15 +138,15 @@
|
|
138
138
|
Hopefully my explanation is understandable! Positive/negative lookahead/-behind can be really useful so it's a good thing to learn, you can read more about it here: https://www.regular-expressions.info/lookaround.html
|
139
139
|
:replies:
|
140
140
|
- :author: spr00ge
|
141
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboo5if
|
141
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboo5if
|
142
142
|
:body: So the lookahead is not captured, thus does not consume, but you group it, so it does capture, but does not consume?
|
143
143
|
:replies:
|
144
144
|
- :author: Sharparam
|
145
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbs8pqb
|
145
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbs8pqb
|
146
146
|
:body: Yep. It's a neat little "trick".
|
147
147
|
:replies: []
|
148
148
|
- :author: Annual-Management613
|
149
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbivf6n
|
149
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbivf6n
|
150
150
|
:body: |-
|
151
151
|
```ruby
|
152
152
|
# frozen_string_literal: true
|
@@ -183,7 +183,7 @@
|
|
183
183
|
```
|
184
184
|
:replies: []
|
185
185
|
- :author: RelativeLead5
|
186
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboikqz
|
186
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboikqz
|
187
187
|
:body: |-
|
188
188
|
PART 1
|
189
189
|
|
@@ -223,7 +223,7 @@
|
|
223
223
|
```
|
224
224
|
:replies: []
|
225
225
|
- :author: Potential-Series-105
|
226
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbovuqu
|
226
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbovuqu
|
227
227
|
:body: |-
|
228
228
|
143 bytes solution
|
229
229
|
|
@@ -232,7 +232,7 @@
|
|
232
232
|
```
|
233
233
|
:replies:
|
234
234
|
- :author: eregontp
|
235
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbqg6sl
|
235
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbqg6sl
|
236
236
|
:body: |-
|
237
237
|
Nice! I learned the $\< trick, $\< is ARGF and that's still Enumerable in lines like IO in the old days. Also cute trick to use index + the extra 0. I golfed my solution with these 2 tricks and funny enough it's 143 bytes too:
|
238
238
|
|
@@ -250,7 +250,7 @@
|
|
250
250
|
```
|
251
251
|
:replies:
|
252
252
|
- :author: Potential-Series-105
|
253
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbzis2a
|
253
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbzis2a
|
254
254
|
:body: |-
|
255
255
|
I sat down with a colleague and now we are down to 133 bytes
|
256
256
|
|
@@ -259,11 +259,11 @@
|
|
259
259
|
```
|
260
260
|
:replies:
|
261
261
|
- :author: eregontp
|
262
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbzu2vy
|
262
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbzu2vy
|
263
263
|
:body: Neat! I was also thinking about using to\_i but that returns 0 for letters, but swapping and doing the index first fixes it nicely.
|
264
264
|
:replies: []
|
265
265
|
- :author: vikingly56
|
266
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbiqa9h
|
266
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbiqa9h
|
267
267
|
:body: |-
|
268
268
|
```ruby
|
269
269
|
pt 1.
|
@@ -308,25 +308,25 @@
|
|
308
308
|
```
|
309
309
|
:replies: []
|
310
310
|
- :author: HAEC_EST_SPARTA
|
311
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbnj78f
|
311
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbnj78f
|
312
312
|
:body: |-
|
313
313
|
##### [Solution on sourcehut](https://git.sr.ht/%7Eawsmith/advent-of-code/tree/2023-ruby/item/lib/day01.rb)
|
314
314
|
|
315
315
|
TIL about [`Array#values_at`](https://docs.ruby-lang.org/en/3.2/Array.html#method-i-values_at), which allows for multiple indices to be extracted from an array with a single function call. Very convenient for writing semi-point-free code!
|
316
316
|
:replies:
|
317
317
|
- :author: Sensanaty
|
318
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbo2695
|
318
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbo2695
|
319
319
|
:body: |-
|
320
320
|
Could you explain the `_1` you're using, not sure I understand where that's coming from or what exactly it's doing?
|
321
321
|
|
322
322
|
Is it something to do with `Enumerable`, where `_1` accesses the first argument of the block without having to do the usual `{ |arg| arg }` thing? So in this case `arg == _1`? If so could you point me to the docs somewhere where this is outline, can't say I've ever seen it before in Ruby code
|
323
323
|
:replies:
|
324
324
|
- :author: HAEC_EST_SPARTA
|
325
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbp9nte
|
325
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbp9nte
|
326
326
|
:body: Ah, that's a [numbered block argument](https://zverok.space/blog/2023-10-11-syntax-sugar1-numeric-block-args.html), which does indeed work as you've explained. Regrettably, I can't find any actual documentation on this feature, but the linked blog post gives a good summary.
|
327
327
|
:replies: []
|
328
328
|
- :author: framsberg
|
329
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbil2hi
|
329
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbil2hi
|
330
330
|
:body: |-
|
331
331
|
```ruby
|
332
332
|
$numarr = ['one','two','three','four','five','six','seven','eight','nine']
|
@@ -356,14 +356,14 @@
|
|
356
356
|
```
|
357
357
|
:replies: []
|
358
358
|
- :author: spr00ge
|
359
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbj4ple
|
359
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbj4ple
|
360
360
|
:body: |-
|
361
361
|
I tripped over the overlapping matches with my regex solution :/
|
362
362
|
|
363
363
|
[paste](https://topaz.github.io/paste/#XQAAAQC1AwAAAAAAAAAQaJUMpn+lCZflRBwxodKX//AEf+EAnsY4VEwo5ziNF87EhpHoNhV4NbzaWwAFuuaAvPWppUim00GJ/4+40YBs0yvm4GWMrVF0S+yDpQo+lpD5OZfomphc+csJ8LH1MnntHzdIZZQBir75b2n/JoVs+eTwu6gqB/aonuAAjLm9qW1XwzGLm8xHOhp4qxWMpYQPb8dXBwjqr2PibvtHsBMcE83XlTNW4Uqr7I5TfDA301epVGCkxwn234pvcVNBHony93+mR0zMYTWVpyfwcODsYDntlS2uDkUdcb9S1j79edg6GpCAe8zPE1g1HrIjo7J6H+7VCcxlXQBZ8ELIBkzO10gJV2WJm4pBJz6mHYf8x2IS4hZO5ha05WYoIXS0yrAjnrfgAo9EfgaDmUgZbKwiaxrQzbGdRmEiVxf/eIVs5EV4MtSwPgoY43bic7cQFSL93ibLGGiXQLqyf09Ip2l+exIOHcHwb3MK+IozDf90BxKJ5e4YwSrcnWYRIlTSHodBTBmpPEdHi3UqIp+GD4jxolnaQiv/Ms+4AA==)
|
364
364
|
:replies: []
|
365
365
|
- :author: careyi4
|
366
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbjjylt
|
366
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbjjylt
|
367
367
|
:body: |-
|
368
368
|
Little bit tricky today for a day 1 puzzle!
|
369
369
|
|
@@ -372,7 +372,7 @@
|
|
372
372
|
[Walkthrough Video](https://youtu.be/0LcOCg6YgXQ)
|
373
373
|
:replies: []
|
374
374
|
- :author: eregontp
|
375
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbk2qvm
|
375
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbk2qvm
|
376
376
|
:body: |-
|
377
377
|
[Allez Cuisine!]
|
378
378
|
|
@@ -386,7 +386,7 @@
|
|
386
386
|
```
|
387
387
|
:replies: []
|
388
388
|
- :author: csrcordeiro
|
389
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbkvci9
|
389
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbkvci9
|
390
390
|
:body: |-
|
391
391
|
Part of it was "inspired" by someone in this megathread but I couldn't find the comment to say thanks. So... here it is:
|
392
392
|
|
@@ -425,11 +425,11 @@
|
|
425
425
|
```
|
426
426
|
:replies:
|
427
427
|
- :author: JelloRough
|
428
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbl89ae
|
428
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbl89ae
|
429
429
|
:body: '"(?="'
|
430
430
|
:replies: []
|
431
431
|
- :author: 6f937f00-3166-11e4-8
|
432
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbl79zx
|
432
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbl79zx
|
433
433
|
:body: |-
|
434
434
|
```ruby
|
435
435
|
def part_one(file)
|
@@ -452,7 +452,7 @@
|
|
452
452
|
```
|
453
453
|
:replies: []
|
454
454
|
- :author: SleepingInsomniac
|
455
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbld1qf
|
455
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbld1qf
|
456
456
|
:body: |-
|
457
457
|
Part 1
|
458
458
|
|
@@ -547,7 +547,7 @@
|
|
547
547
|
```
|
548
548
|
:replies: []
|
549
549
|
- :author: Papitz
|
550
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kblg77b
|
550
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kblg77b
|
551
551
|
:body: |-
|
552
552
|
```ruby
|
553
553
|
WRITTEN_NUMBERS = {
|
@@ -575,14 +575,14 @@
|
|
575
575
|
```
|
576
576
|
:replies: []
|
577
577
|
- :author: cwby_bbop
|
578
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbmxtpw
|
578
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbmxtpw
|
579
579
|
:body: |-
|
580
580
|
I cannot get the syntax highlighting to format properly:
|
581
581
|
|
582
582
|
[https://github.com/ealvar3z/aoc-2023/blob/master/day01.rb](https://github.com/ealvar3z/aoc-2023/blob/master/day01.rb)
|
583
583
|
:replies: []
|
584
584
|
- :author: TevePinch
|
585
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbmyafg
|
585
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbmyafg
|
586
586
|
:body: |-
|
587
587
|
```ruby
|
588
588
|
total = 0
|
@@ -604,15 +604,15 @@
|
|
604
604
|
```
|
605
605
|
:replies:
|
606
606
|
- :author: chizel999
|
607
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbn0d1a
|
607
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbn0d1a
|
608
608
|
:body: damn thats some compact solution. nice
|
609
609
|
:replies: []
|
610
610
|
- :author: Sensanaty
|
611
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboi0x2
|
611
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboi0x2
|
612
612
|
:body: Really cool solution
|
613
613
|
:replies: []
|
614
614
|
- :author: Sensanaty
|
615
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbo5p4v
|
615
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbo5p4v
|
616
616
|
:body: |-
|
617
617
|
[LANGUAGE: Ruby 3.2.1]
|
618
618
|
|
@@ -625,7 +625,7 @@
|
|
625
625
|
[Raw Text](https://raw.githubusercontent.com/Sensanaty/aoc2023-ruby/master/days/1/main.rb)
|
626
626
|
:replies: []
|
627
627
|
- :author: TailorSubstantial863
|
628
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbzr6nv
|
628
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbzr6nv
|
629
629
|
:body: |-
|
630
630
|
A bit late to the party, but I like to refactor into something professional looking before submitting. I was able to combine both parts into a single method and pass in the correct regex to make it work like a charm.
|
631
631
|
|
@@ -668,15 +668,15 @@
|
|
668
668
|
```
|
669
669
|
:replies:
|
670
670
|
- :author: Educational-Sky-1560
|
671
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc2w00e
|
671
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc2w00e
|
672
672
|
:body: Do you have had input data as csv file or?
|
673
673
|
:replies:
|
674
674
|
- :author: TailorSubstantial863
|
675
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc41vix
|
675
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kc41vix
|
676
676
|
:body: I just included it as a text file and read it in as is. Nothing fancy.
|
677
677
|
:replies: []
|
678
678
|
- :author: Symbroson
|
679
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbixl2s
|
679
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbixl2s
|
680
680
|
:body: |-
|
681
681
|
First time ruby, day 1 solutionMy initial part two solution was way uglier - this is the line optimized version
|
682
682
|
|
@@ -698,7 +698,7 @@
|
|
698
698
|
```
|
699
699
|
:replies: []
|
700
700
|
- :author: maxforasteiro
|
701
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbj9wm2
|
701
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbj9wm2
|
702
702
|
:body: |-
|
703
703
|
I love one-liners:
|
704
704
|
|
@@ -717,7 +717,7 @@
|
|
717
717
|
```
|
718
718
|
:replies: []
|
719
719
|
- :author: PassifloraCaerulea
|
720
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbjhsq9
|
720
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbjhsq9
|
721
721
|
:body: |-
|
722
722
|
```ruby
|
723
723
|
to_digit = %w(one two three four five six seven eight nine).
|
@@ -739,7 +739,7 @@
|
|
739
739
|
```
|
740
740
|
:replies: []
|
741
741
|
- :author: ldhmachin
|
742
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbjjvyg
|
742
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbjjvyg
|
743
743
|
:body: |-
|
744
744
|
Ruby:
|
745
745
|
|
@@ -776,7 +776,7 @@
|
|
776
776
|
```
|
777
777
|
:replies: []
|
778
778
|
- :author: the_notic
|
779
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbkldbv
|
779
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbkldbv
|
780
780
|
:body: |-
|
781
781
|
```ruby
|
782
782
|
def get_first_and_last_number(str)
|
@@ -787,14 +787,14 @@
|
|
787
787
|
```
|
788
788
|
:replies: []
|
789
789
|
- :author: vinc686
|
790
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbksrlj
|
790
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbksrlj
|
791
791
|
:body: |-
|
792
792
|
```ruby
|
793
793
|
p ARGF.read.split.map { |l| l.scan(/\d/).values_at(0, -1).join.to_i }.sum
|
794
794
|
```
|
795
795
|
:replies: []
|
796
796
|
- :author: glebm
|
797
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboj47u
|
797
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboj47u
|
798
798
|
:body: |-
|
799
799
|
Part 1:
|
800
800
|
|
@@ -838,14 +838,14 @@
|
|
838
838
|
```
|
839
839
|
:replies:
|
840
840
|
- :author: dafarmerz
|
841
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbouhpm
|
841
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbouhpm
|
842
842
|
:body: Did you get the star for the Part 2 with this code? I am asking because I got the same result with your code that I had running mine.....However, I get no star for Part 2 because the response is incorrect.
|
843
843
|
:replies:
|
844
844
|
- :author: glebm
|
845
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboxbzw
|
845
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kboxbzw
|
846
846
|
:body: Yeah I did, odd that you didn't, perhaps something is wrong with your input file?
|
847
847
|
:replies:
|
848
848
|
- :author: dafarmerz
|
849
|
-
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbp76l5
|
849
|
+
:url: https://www.reddit.com/r/adventofcode/comments/1883ibu/2023_day_1_solutions/kbp76l5
|
850
850
|
:body: Well...its the same from Part 1 so it should be good. I just messaged the MODs
|
851
851
|
:replies: []
|
@@ -1,13 +1,13 @@
|
|
1
1
|
---
|
2
2
|
- :author: apollo701
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kdci5az
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kdci5az
|
4
4
|
:body: |-
|
5
5
|
[https://github.com/JasonDorn/advent-of-code/tree/master/day2-cube-conundrum](https://github.com/JasonDorn/advent-of-code/tree/master/day2-cube-conundrum)
|
6
6
|
|
7
7
|
Took an OOP approach for part 1/2. Could use some more cleanup, would probably combine my two service classes into a GameMangement object or something that knows how to check valid games and powers
|
8
8
|
:replies: []
|
9
9
|
- :author: wdomburg
|
10
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kcikjcf
|
10
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kcikjcf
|
11
11
|
:body: |-
|
12
12
|
I was happy with how little modification there was from part 1:
|
13
13
|
|
@@ -20,7 +20,7 @@
|
|
20
20
|
> It even got smaller!
|
21
21
|
:replies: []
|
22
22
|
- :author: Potential-Series-105
|
23
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbzji27
|
23
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbzji27
|
24
24
|
:body: |-
|
25
25
|
turns out part 1 can be really optimized with a perfect hash function. 83 bytes total.
|
26
26
|
|
@@ -29,7 +29,7 @@
|
|
29
29
|
```
|
30
30
|
:replies: []
|
31
31
|
- :author: Sharparam
|
32
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnfoep
|
32
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnfoep
|
33
33
|
:body: |-
|
34
34
|
```ruby
|
35
35
|
input = ARGF.read.lines
|
@@ -64,14 +64,14 @@
|
|
64
64
|
Took longer than day 1 due to not grasping all the text at first.
|
65
65
|
:replies: []
|
66
66
|
- :author: HAEC_EST_SPARTA
|
67
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnnift
|
67
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnnift
|
68
68
|
:body: |-
|
69
69
|
##### [Solution on sourcehut](https://git.sr.ht/%7Eawsmith/advent-of-code/tree/2023-ruby/item/lib/day02.rb)
|
70
70
|
|
71
71
|
Nothing particularly groundbreaking in today's solution, but I'm pretty pleased with its conciseness: being able to write the parser and solutions to both parts in single expressions is always quite satisfying.
|
72
72
|
:replies: []
|
73
73
|
- :author: 6f937f00-3166-11e4-8
|
74
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnqt01
|
74
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnqt01
|
75
75
|
:body: |-
|
76
76
|
```ruby
|
77
77
|
def part_one(lines)
|
@@ -106,7 +106,7 @@
|
|
106
106
|
```
|
107
107
|
:replies: []
|
108
108
|
- :author: eregontp
|
109
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbqk1tn
|
109
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbqk1tn
|
110
110
|
:body: |-
|
111
111
|
Part 1 in 96 bytes:
|
112
112
|
|
@@ -115,11 +115,11 @@
|
|
115
115
|
```
|
116
116
|
:replies: []
|
117
117
|
- :author: cwby_bbop
|
118
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbneo94
|
118
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbneo94
|
119
119
|
:body: "[https://github.com/ealvar3z/aoc-2023/blob/master/day02.rb](https://github.com/ealvar3z/aoc-2023/blob/master/day02.rb)"
|
120
120
|
:replies:
|
121
121
|
- :author: snowe2010
|
122
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnim17
|
122
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnim17
|
123
123
|
:body: |-
|
124
124
|
oh yours is really similar to mine. https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2\_solutions/kbnehwa/
|
125
125
|
|
@@ -128,32 +128,32 @@
|
|
128
128
|
I took some of your ideas around scan and implemented them into my golf solution and got 133! Our solutions look super different, but came out to almost the same length. https://github.com/snowe2010/advent-of-code/blob/master/ruby\_aoc/2023/day02/day02.rb#L108-L112
|
129
129
|
:replies: []
|
130
130
|
- :author: vikingly56
|
131
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnmpb7
|
131
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnmpb7
|
132
132
|
:body: |-
|
133
133
|
[Part 1](https://topaz.github.io/paste/#XQAAAQBNBAAAAAAAAAAxm8nOkzLf4JvunUP6t9pRtuGOkmJHAufY4vQu0GpflVYEXt/7dXdFCFOTrbpPSYpK17U9tsOfHPM6UlFib6EkLOBdjWaElVZtLK6WFosU3zppJ/41+eDPQ0goFWQDYECR6iWYOfESZbtFUKOZar33scrvWN9/73QtlsiwEQ5suGfX2dHHSlsUUWDC/ZUC+/a2fiw2MvXnwxUQU6Bo6q2oAaeTWQTo14A5r3PrusClLkjkY1OdmJuHR3Yc1GBB/Uzk9qNgWmnKHkdYIH9TXCNLfjLTGQzgJR0QeoMF/aZAJOzZA5GIjlDYTwZu1z95TY/ZV4BFkVB3Z/Jv808+RrNXUOjCR02drI0hhShfGLgujBOE+awebvMMCfh1RijB7Sp6tC+wkeM6QwTLn07YngiGNPLzz4cVEvxvcduESLSV4MNDD0rSBVoDN9If1JugyTTQVxoUiB+hnnLYjMBEIIiHZbVpibgra7Mk3D6fuhXnGdVIzgwdmeRKCtMuRERAZnoxFMXo5VYSuPK2aJUAIOLVuLp5tAo++tJsX+p1CTMf5t8sAbNbIZpTjC4IynZhkrGIWj5+WV4Q0bxKjiOSCHckSyZcrf8y6SUA)
|
134
134
|
|
135
135
|
[Part 2](https://topaz.github.io/paste/#XQAAAQB4AwAAAAAAAAAyGUj/TwpvLe0gsyFT8iZOPN9EedSymx3muo0auG1mGPtkRDoowDfNoD2XUYqR6zwVGLRBG3GC31kGTgZkOc9a8AVtoKhS6c2alQZFy/xwOjfn6C2NmLJlyJTtjXyU9KMBFRHHXapS6HDxqGc1cluKil1HJ2F1ctUIDQVnwZ9WBjNTHuPd3UYdFtbhpMvi4rV8VOxE6QigAMTxRICrrVqUzR6ToWwTpEF9T+TdFbXR1zmtPpWM8yEvdNuMFZSWNqDPEDfIf5Gc7ANiv/cIJ5fsY/oA9dun+TuC13ltdE5YezY8Ce08ZnziMRNTuAjiQmQi443fLd7z0gcjaSFq18WaUnwPNsPG0DuTTw8tcBROkAB+JH+EqpWMomt1ME1XJWGYCFAPGhN1uhsZnX8JzYrvaBAzoZjI9QuVX2daAirHnMvAEgnIDWNZxM5EDqJrmKT+v/dG17uuF/zd9f+ccaAso3fSXxcB8FYGkVxy0WJKKUAMWl//32YMhw==)
|
136
136
|
:replies: []
|
137
137
|
- :author: PassifloraCaerulea
|
138
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnn5hs
|
138
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnn5hs
|
139
139
|
:body: |-
|
140
140
|
[paste](https://topaz.github.io/paste/#XQAAAQBwBQAAAAAAAAAjmEmmZ0F3geH2HS941iDpkRJhWDNw+mFEzIaPDt0a7Lu2lgmr2JUWvBhN/4fVM2VA5i+470PBXuJs0lvlR02ICCg2zvy0c46svch3YBFAfPbMBJ6hX3oIVqA5e/7td2YK+LR7KxNa67+ontMR51shq87rdbVJB3sEWmgTkJd0CaRWKuSdQujZ/nTdRFCmgUJrlskroa9boPf5oxKhfQlZEubf3hdx2zJxhxI4n7aDyg3GiY99VkCvGCMOP1t44OUaaR0Qoe6bQhOAAQZWWXgHpXBQF01eRv3V46X9Z4HNARzs9qceyjFO1CMSPFuo5kpcQXMmwSCM3YKrBZQoUiuV6IUlvmipdCPfn2KHocqmxaDa3s2w82kJ4rLePrJQkRPvycBu+jaN+N+H0hgu6HMi9jZS2alcD4gGM1OCz6j+5s9sfyu2xBCXTlXX6fCtWsIQZHYyishnl2v9wZcaBCj+4NCBxayv7Mfa3VF0WcRp6JvL7P2oi3ZR26oFgBSiXm0H2iY459xzk/FNZ8IEKIAZY3FCwec6FdMQEtclN7x6z5twZqMtAVrXdRTDMghWq8Yx1p4No1nVFJUzRKCSj+8iq+g42oFvujfvUtvCSM9yKh0CPjXx3H1FZ/dTFpH7ktGHYoCh6QmqXveVYhMVcALz6Ynu5XbmVb0gUmax4SS50T/kBzrzC2WVb5P2OeAYGvoUSKvIAf1AgP1KG3OIzhHE4UX0vGYmSeTKynCGrM1fY8j3osvtrlm+b8yp5U+MCEJx6jUss/IfttLXkMxP0hb5ntmQ4y3DAmzW5s6rkQ3Alz52ydPKr/2hVsg=)
|
141
141
|
|
142
142
|
Disappointingly large amount of far too conventionally structured code :-P Easier problem than yesterday even though it took me longer. Y'all are making me want to finally try out Smalltalk to work these problems, but opening up a Pharo image I'm remembering why I haven't before: such a weird interface I have a lot of trouble figuring out :(
|
143
143
|
:replies: []
|
144
144
|
- :author: vinc686
|
145
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbozeir
|
145
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbozeir
|
146
146
|
:body: 'Pretty straightforward but no one liner this time: https://github.com/vinc/advent-of-code/tree/master/ruby/2023/02'
|
147
147
|
:replies: []
|
148
148
|
- :author: snowe2010
|
149
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnehwa
|
149
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnehwa
|
150
150
|
:body: |-
|
151
151
|
https://github.com/snowe2010/advent-of-code/blob/master/ruby\_aoc/2023/day02/day02.rb
|
152
152
|
|
153
153
|
Easier than day 1. I'll be adding code golf solutions to this as well over the next hour or so.
|
154
154
|
:replies: []
|
155
155
|
- :author: Annual-Management613
|
156
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnoh0a
|
156
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbnoh0a
|
157
157
|
:body: |-
|
158
158
|
Today it was an easy day, my solution is really simple and nothing to be specially proud of:
|
159
159
|
|
@@ -197,18 +197,18 @@
|
|
197
197
|
```
|
198
198
|
:replies: []
|
199
199
|
- :author: the_bengal_lancer
|
200
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbntjmf
|
200
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbntjmf
|
201
201
|
:body: 'map/filter/reduce boogaloo: https://gist.github.com/andrewzah/0e71e3b9fcc0984ed1808886085960a3'
|
202
202
|
:replies: []
|
203
203
|
- :author: brightside_bitch
|
204
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbo18su
|
204
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbo18su
|
205
205
|
:body: |-
|
206
206
|
[paste](https://github.com/dorianamouroux/advent-of-code/blob/main/2023/day02/day02.rb)
|
207
207
|
|
208
208
|
Learning Ruby. Pretty happy with my solution and the use of .scan / .match to parse
|
209
209
|
:replies: []
|
210
210
|
- :author: glebm
|
211
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbo61gt
|
211
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbo61gt
|
212
212
|
:body: |-
|
213
213
|
Part 1:
|
214
214
|
|
@@ -269,7 +269,7 @@
|
|
269
269
|
```
|
270
270
|
:replies: []
|
271
271
|
- :author: RelativeLead5
|
272
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kboke1w
|
272
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kboke1w
|
273
273
|
:body: |-
|
274
274
|
PART 1
|
275
275
|
|
@@ -312,7 +312,7 @@
|
|
312
312
|
```
|
313
313
|
:replies: []
|
314
314
|
- :author: careyi4
|
315
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kboo1la
|
315
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kboo1la
|
316
316
|
:body: |-
|
317
317
|
Easier than yesterday!!
|
318
318
|
|
@@ -321,7 +321,7 @@
|
|
321
321
|
[Video Walkthrough](https://youtu.be/WU_OB8X7OWQ)
|
322
322
|
:replies: []
|
323
323
|
- :author: Sensanaty
|
324
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbp3ocg
|
324
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbp3ocg
|
325
325
|
:body: |-
|
326
326
|
[LANGUAGE: Ruby 3.2.1]
|
327
327
|
|
@@ -334,7 +334,7 @@
|
|
334
334
|
[Raw Text](https://raw.githubusercontent.com/Sensanaty/aoc2023-ruby/master/days/2/main.rb)
|
335
335
|
:replies: []
|
336
336
|
- :author: systemnate
|
337
|
-
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbp7a7s
|
337
|
+
:url: https://www.reddit.com/r/adventofcode/comments/188w447/2023_day_2_solutions/kbp7a7s
|
338
338
|
:body: |-
|
339
339
|
```ruby
|
340
340
|
data = open("./input.txt").read.split("\n")
|