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: joeyGibson
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi5hv5i
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi5hv5i
|
4
4
|
:body: |-
|
5
5
|
After seeing multiple submissions in APL by /u/jayfoad and /u/ka-splam, I started experimenting with Dyalog APL, and decided to take a whack at re-implementing some of the AoC challenges in APL (I did them all in Ruby the first time). Starting with Day 1, which took me many hours, I came up with this. It's probably shitty APL code, but it's mine. :-) I tried to "think in APL", and not in procedural languages, but I just couldn't come up with those idioms, yet.
|
6
6
|
|
@@ -45,15 +45,15 @@
|
|
45
45
|
Edit: I looked at someone else's code, and realized I could remove one of the functions, if I changed how I read in the text file.
|
46
46
|
:replies:
|
47
47
|
- :author: jayfoad
|
48
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giau5xg
|
48
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giau5xg
|
49
49
|
:body: 'Here''s an idea for a completely different array oriented solution: you''re looking for a value x such that both x and 2020-x are present in VALS. So you could try applying the APL set functions (dyadic `⍳` `∊` `∩` `∪` `~`) to VALS and 2020-VALS.'
|
50
50
|
:replies: []
|
51
51
|
- :author: ka-splam
|
52
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi7q3i2
|
52
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi7q3i2
|
53
53
|
:body: "Well done!\n\n> I tried to \"think in APL\", and not in procedural languages, but I just couldn't come up with those idioms, yet.\n\nI've been a beginner in APL for a couple of years, and this is by far the hardest part - much harder than the weird symbols - \"okay but ... how do I _solve problems_ using arrays?\" :D I don't fault you at all for using loops. This `others←VALS~val` and `pos/others` are nice bits of array thinking, just to make a point of calling that out \U0001F44D\n\nOn your code, I know it's possible to solve the problems in one-liners, and you can see that code in other people's answers if you want to go there so I'm not saying \"do it completely differently\" - code you write is more fun than code other people wrote; I'm going to throw some comments, not actually saying you ought to use them, just hoping to share some things APL can do:\n\n```ruby\nFerret←{⍵[2]}\nR←Ferret¨(⎕VFI¨LINES)\n```\n\nThat `⍵[2]` to get the second item can be written `2⊃⍵` \"2 pick\" or \"pick 2nd item of omega\" (as a rule of thumb they try to put control instructions like what to pick on the left of builtins, and data to be processed on the right), and that would let you write it without the `{}` dfn as `2⊃¨ (⎕VFI¨LINES)` \"pick the second item of each of...\".\n\nAnother way, because it's a fairly unique-y APL thing, if you raise the dimension of the ⎕VFI result with `↑` \"mix\", instead of a 1D list it turns into a 2D array, and then you can select the entire second column with `[;2]` in one move: `(↑⎕VFI¨LINES)[;2]`.\n\nHere `⊃¨⊃¨R` looks like you're un-nesting or disclosing the numbers? Nesting and enclosing always trips me up; I suspect you're doing `⊃¨` twice to make suuuure? Monadic `∊` is that kind of blunt tool \"flatten everything, lose the structure and get me all the values in a simple array\", and `∊R` might do the same thing here.\n\nThis line `R←R,pos/others` looks like it's appending to a list, and APL can do that with `,←` as in `R,←pos/others`. As an aside, in PowerShell catenating onto an array can be done with `$array += $item` which is a special-case use of `+=` that hardly shows up anywhere else, but APL is much cooler and can combine a lot of functions with `←` assignment not limited to just addition or catenation, it can do things like:\n\n```ruby\n array ← 1 2 3 4 5 6 7 8 9 10\n array ⌊← 5\n array\n1 2 3 4 5 5 5 5 5 5\n```\n\nI'm not sure if that's always a shorthand for writing the variable name twice `array ← array ⌊ 5` or if there's more to it than that, but it would make it less annoying to use a longer variable name `result,←pos/others` instead of `result←result,pos/others`.\n\nAnyway, good job though, it's made me happy :)"
|
54
54
|
:replies:
|
55
55
|
- :author: joeyGibson
|
56
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi7tamc
|
56
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi7tamc
|
57
57
|
:body: |-
|
58
58
|
Ooo, yes! More advice for me to try out tonight! Thanks! I actually removed that entire `cvt` function, where `Ferret` was, after seeing some other code that did what I wanted better. Basically, I was reading the file, and getting a multiply-nested structure, from which I needed to get the integer values, and this is what I came up with. Once I saw an example, I was able to remove that function, and just replace my
|
59
59
|
|
@@ -70,7 +70,7 @@
|
|
70
70
|
and that got me a single-level vector with usable integers in it.
|
71
71
|
:replies: []
|
72
72
|
- :author: jayfoad
|
73
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi655c0
|
73
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi655c0
|
74
74
|
:body: |-
|
75
75
|
Great! The only thing about your code that really stands out as un-idiomatic is the :For loops. To get the best out of APL you should really strive to do operations on whole arrays at a time. The practical reason for this is: it'll run faster. The more important reason is: it unlocks a whole new way of looking at problems, with a higher level of abstraction.
|
76
76
|
|
@@ -81,7 +81,7 @@
|
|
81
81
|
Incidentally [The APL Orchard](https://chat.stackexchange.com/rooms/52405/the-apl-orchard) is a great place for learning and discussing APL.
|
82
82
|
:replies:
|
83
83
|
- :author: joeyGibson
|
84
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi9vjan
|
84
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi9vjan
|
85
85
|
:body: |-
|
86
86
|
If `data` contains `1721 979 366 299 675 1456`, and I run
|
87
87
|
|
@@ -99,7 +99,7 @@
|
|
99
99
|
How can I get the value at that junction? I tried to figure out how to have the anonymous function return `⍵` if the condition is true, but I couldn't figure out how to do it. I feel like I'm close, but not sure where to go next.
|
100
100
|
:replies:
|
101
101
|
- :author: jayfoad
|
102
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giad5bl
|
102
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giad5bl
|
103
103
|
:body: |-
|
104
104
|
Good question! Boolean arrays, and especially vectors, are used a lot. One thing you can do with a Boolean vector is use it to select items from another vector with Compress `/`:
|
105
105
|
|
@@ -126,14 +126,14 @@
|
|
126
126
|
Yes it's a bit wasteful generating the whole of `∘.×⍨data` just to select one or two items from it, but I bet you'll find it still runs pretty fast!
|
127
127
|
:replies:
|
128
128
|
- :author: joeyGibson
|
129
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giat4pz
|
129
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giat4pz
|
130
130
|
:body: |-
|
131
131
|
I keep seeing the `2020=⍺+⍵` style, which reminds me of how some people write Java code with `if (null == foo)...`, which annoys me greatly. Knowing _why_ APL code is written that way makes total sense, and I will certainly adopt that style.
|
132
132
|
|
133
133
|
As for your other points I will definitely be working through them tonight. Thank you!
|
134
134
|
:replies: []
|
135
135
|
- :author: joeyGibson
|
136
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi9zvy8
|
136
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi9zvy8
|
137
137
|
:body: |-
|
138
138
|
After some more testing, and reading, I came up with
|
139
139
|
|
@@ -144,22 +144,22 @@
|
|
144
144
|
which works, but all the parens are kind of smelly, I think.
|
145
145
|
:replies:
|
146
146
|
- :author: jayfoad
|
147
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giadj31
|
147
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giadj31
|
148
148
|
:body: |-
|
149
149
|
Yup, that works. Some of the outer parens are just not needed: `×/∊(data∘.{(⍺+⍵)=2020:⍵ ⋄ 0}data)~0`
|
150
150
|
|
151
151
|
Another APLism to to use Booleans as the mathematical values 0 and 1 (this is "Iverson's convention" and [Knuth says it's OK](https://arxiv.org/pdf/math/9205211.pdf)). So your lambda could be written as `{((⍺+⍵)=2020)×⍵}` or `{⍵×2020=⍺+⍵}`.
|
152
152
|
:replies:
|
153
153
|
- :author: joeyGibson
|
154
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giasxev
|
154
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/giasxev
|
155
155
|
:body: I have seen uses of boolean results like that, but it didn't occur to me to use that here. That definitely cuts out some of the fluff.
|
156
156
|
:replies: []
|
157
157
|
- :author: joeyGibson
|
158
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi6bk46
|
158
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gi6bk46
|
159
159
|
:body: YES! Thank you! This is the kind of feedback I was hoping for. I knew that the `:For` loops smelled bad, I just couldn't figure out how to get the same effect any other way. I'm only about 250 pages into "Mastering Dyalog APL", so I'm still finding my way. I will definitely investigate this tonight.
|
160
160
|
:replies: []
|
161
161
|
- :author: blafunke
|
162
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geqtqg4
|
162
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geqtqg4
|
163
163
|
:body: |-
|
164
164
|
Late to the party, but I tried to dress it up a bit to make up for tardiness.
|
165
165
|
|
@@ -184,7 +184,7 @@
|
|
184
184
|
```
|
185
185
|
:replies: []
|
186
186
|
- :author: Krakhan
|
187
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geojn61
|
187
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geojn61
|
188
188
|
:body: |-
|
189
189
|
**Ruby**
|
190
190
|
|
@@ -201,7 +201,7 @@
|
|
201
201
|
```
|
202
202
|
:replies: []
|
203
203
|
- :author: Sharparam
|
204
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8dg41
|
204
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8dg41
|
205
205
|
:body: |-
|
206
206
|
## [Ruby (428/369)](https://github.com/Sharparam/advent-of-code/blob/master/2020/day1/solution.rb)
|
207
207
|
|
@@ -213,21 +213,21 @@
|
|
213
213
|
```
|
214
214
|
:replies:
|
215
215
|
- :author: "[deleted]"
|
216
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8nz8m
|
216
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8nz8m
|
217
217
|
:body: |-
|
218
218
|
Nice! This is very close to my solution. I love ruby's combinatorics functions.
|
219
219
|
|
220
220
|
(You don't need that ampersand in #reduce)
|
221
221
|
:replies:
|
222
222
|
- :author: Sharparam
|
223
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8rjq5
|
223
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8rjq5
|
224
224
|
:body: |-
|
225
225
|
Yeah the built-in combinatorics stuff is a lifesaver, I miss a lot of these built-in things when working in other languages.
|
226
226
|
|
227
227
|
Didn't know that reduce could take a plain symbol for the method, thanks for pointing it out!
|
228
228
|
:replies: []
|
229
229
|
- :author: Piggelinmannen
|
230
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geax0kn
|
230
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geax0kn
|
231
231
|
:body: |-
|
232
232
|
Hi!First time posting! :) Solution in ruby:
|
233
233
|
|
@@ -254,7 +254,7 @@
|
|
254
254
|
EDIT: reddit code blocks...
|
255
255
|
:replies: []
|
256
256
|
- :author: shandley256
|
257
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geafdj9
|
257
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geafdj9
|
258
258
|
:body: |-
|
259
259
|
Ruby Part 1
|
260
260
|
|
@@ -265,7 +265,7 @@
|
|
265
265
|
> input.split.map(&:to\_i).combination(3).detect { |tuple| tuple.sum == 2020 }.reduce(:\*)
|
266
266
|
:replies: []
|
267
267
|
- :author: MuumiJumala
|
268
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8rsst
|
268
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8rsst
|
269
269
|
:body: |-
|
270
270
|
Code golf (Ruby)
|
271
271
|
|
@@ -275,7 +275,7 @@
|
|
275
275
|
```
|
276
276
|
:replies:
|
277
277
|
- :author: jtgorn
|
278
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge908p9
|
278
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge908p9
|
279
279
|
:body: |-
|
280
280
|
I prefer this syntax
|
281
281
|
|
@@ -284,7 +284,7 @@
|
|
284
284
|
```
|
285
285
|
:replies: []
|
286
286
|
- :author: odlp
|
287
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8vp59
|
287
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8vp59
|
288
288
|
:body: |-
|
289
289
|
**Ruby**
|
290
290
|
|
@@ -306,7 +306,7 @@
|
|
306
306
|
```
|
307
307
|
:replies: []
|
308
308
|
- :author: DropkickFish
|
309
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geaqgdt
|
309
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/geaqgdt
|
310
310
|
:body: |-
|
311
311
|
Ruby.
|
312
312
|
|
@@ -324,7 +324,7 @@
|
|
324
324
|
```
|
325
325
|
:replies: []
|
326
326
|
- :author: Mermoose
|
327
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gebmpyg
|
327
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gebmpyg
|
328
328
|
:body: |-
|
329
329
|
Ruby:
|
330
330
|
|
@@ -343,7 +343,7 @@
|
|
343
343
|
```
|
344
344
|
:replies: []
|
345
345
|
- :author: jeffers0n
|
346
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gedmx6c
|
346
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gedmx6c
|
347
347
|
:body: |-
|
348
348
|
My solution in Ruby:
|
349
349
|
|
@@ -374,7 +374,7 @@
|
|
374
374
|
`end`
|
375
375
|
:replies: []
|
376
376
|
- :author: combustible
|
377
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gebclbc
|
377
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/gebclbc
|
378
378
|
:body: |-
|
379
379
|
I'll be honest... not sure my heart's in it this year
|
380
380
|
|
@@ -385,7 +385,7 @@
|
|
385
385
|
```
|
386
386
|
:replies: []
|
387
387
|
- :author: frontpageminus
|
388
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8d75b
|
388
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8d75b
|
389
389
|
:body: |-
|
390
390
|
Ruby - 1706 / 1575. Just brute forcing it. Part one:
|
391
391
|
|
@@ -418,7 +418,7 @@
|
|
418
418
|
```
|
419
419
|
:replies: []
|
420
420
|
- :author: jtgorn
|
421
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8yog2
|
421
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge8yog2
|
422
422
|
:body: |-
|
423
423
|
Ruby
|
424
424
|
|
@@ -438,7 +438,7 @@
|
|
438
438
|
```
|
439
439
|
:replies: []
|
440
440
|
- :author: hdf1986
|
441
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge93z7e
|
441
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge93z7e
|
442
442
|
:body: |-
|
443
443
|
My ruby solutions for day 1:
|
444
444
|
|
@@ -447,7 +447,7 @@
|
|
447
447
|
Part 2: [https://github.com/hdf1986/advent-of-code/blob/master/2020/day1/ruby/part2.rb](https://github.com/hdf1986/advent-of-code/blob/master/2020/day1/ruby/part2.rb)
|
448
448
|
:replies: []
|
449
449
|
- :author: '442401'
|
450
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge9809q
|
450
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k4e4lm/2020_day_1_solutions/ge9809q
|
451
451
|
:body: |-
|
452
452
|
**Ruby**
|
453
453
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: Wattswing
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ggzhsf4
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ggzhsf4
|
4
4
|
:body: |-
|
5
5
|
My solution in Ruby
|
6
6
|
|
@@ -44,7 +44,7 @@
|
|
44
44
|
```
|
45
45
|
:replies: []
|
46
46
|
- :author: Krakhan
|
47
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geojqux
|
47
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geojqux
|
48
48
|
:body: |-
|
49
49
|
**Ruby**
|
50
50
|
|
@@ -77,7 +77,7 @@
|
|
77
77
|
```
|
78
78
|
:replies: []
|
79
79
|
- :author: Piggelinmannen
|
80
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecg3rg
|
80
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecg3rg
|
81
81
|
:body: |-
|
82
82
|
Solution in Ruby. Tried to edit it to work with old reddit code blocks, not sure if successfully so...
|
83
83
|
|
@@ -106,7 +106,7 @@
|
|
106
106
|
```
|
107
107
|
:replies: []
|
108
108
|
- :author: infov0re
|
109
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecuxoa
|
109
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecuxoa
|
110
110
|
:body: |-
|
111
111
|
**Ruby** : an anti-golf solution for part 2. (Part 1 is highly similar, with minor differences to the `valid?` method. (I'll take readability over line count). I chose not to use regex because, frankly, then I have two problems (and the line syntax is not complex enough to demand it IMO).
|
112
112
|
|
@@ -157,7 +157,7 @@
|
|
157
157
|
```
|
158
158
|
:replies: []
|
159
159
|
- :author: avoxdesign
|
160
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged2s8x
|
160
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged2s8x
|
161
161
|
:body: |-
|
162
162
|
My solutions in pure Ruby:
|
163
163
|
|
@@ -198,7 +198,7 @@
|
|
198
198
|
```
|
199
199
|
:replies: []
|
200
200
|
- :author: hdf1986
|
201
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged428s
|
201
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged428s
|
202
202
|
:body: |-
|
203
203
|
**Ruby**
|
204
204
|
|
@@ -211,15 +211,15 @@
|
|
211
211
|
EDIT: I've updated the boolean operator in part 2 to be a XOR by suggestion of u/chunes
|
212
212
|
:replies:
|
213
213
|
- :author: "[deleted]"
|
214
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged51aq
|
214
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged51aq
|
215
215
|
:body: "[deleted]"
|
216
216
|
:replies:
|
217
217
|
- :author: hdf1986
|
218
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged6ynd
|
218
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged6ynd
|
219
219
|
:body: That really makes sense, ~~will update it later to include that~~ I've just updated the code to use it. Thank you!
|
220
220
|
:replies: []
|
221
221
|
- :author: Karl_Marxxx
|
222
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geeadpy
|
222
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geeadpy
|
223
223
|
:body: |-
|
224
224
|
Ruby
|
225
225
|
|
@@ -243,7 +243,7 @@
|
|
243
243
|
```
|
244
244
|
:replies: []
|
245
245
|
- :author: bacon-supreme
|
246
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geegd88
|
246
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geegd88
|
247
247
|
:body: |-
|
248
248
|
Using this to re-learn Ruby; wherein one does not know that `array.count(obj)` exists:
|
249
249
|
|
@@ -292,7 +292,7 @@
|
|
292
292
|
```
|
293
293
|
:replies: []
|
294
294
|
- :author: frontpageminus
|
295
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gec97gd
|
295
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gec97gd
|
296
296
|
:body: |-
|
297
297
|
Ruby 84/373
|
298
298
|
|
@@ -313,7 +313,7 @@
|
|
313
313
|
```
|
314
314
|
:replies: []
|
315
315
|
- :author: Sharparam
|
316
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecalhe
|
316
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecalhe
|
317
317
|
:body: |-
|
318
318
|
### [Ruby (706/418)](https://github.com/Sharparam/advent-of-code/blob/master/2020/day2/solution.rb)
|
319
319
|
|
@@ -355,7 +355,7 @@
|
|
355
355
|
```
|
356
356
|
:replies: []
|
357
357
|
- :author: lunarfyr3
|
358
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gech0k6
|
358
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gech0k6
|
359
359
|
:body: |-
|
360
360
|
Another Ruby solution
|
361
361
|
|
@@ -386,7 +386,7 @@
|
|
386
386
|
`puts data.reduce([0,0]) { |acc, line| pw = Pw.new(line); [acc[0] + (pw.valid_a? ? 1:0), acc[1] + (pw.valid_b? ? 1:0)] }`
|
387
387
|
:replies:
|
388
388
|
- :author: jtgorn
|
389
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecpa3j
|
389
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecpa3j
|
390
390
|
:body: |-
|
391
391
|
> puts data.reduce(0) { |acc, pw| Pw.new(pw).valid\_a? ? acc+1 : acc } # part 1
|
392
392
|
|
@@ -397,7 +397,7 @@
|
|
397
397
|
```
|
398
398
|
:replies: []
|
399
399
|
- :author: Piggelinmannen
|
400
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecqnjd
|
400
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecqnjd
|
401
401
|
:body: |-
|
402
402
|
I like the small class! The reduce calls can be replaced by count, like so:
|
403
403
|
|
@@ -406,11 +406,11 @@
|
|
406
406
|
`puts data.count { |pw| Pw.new(pw).valid_b? } # part 2`
|
407
407
|
:replies:
|
408
408
|
- :author: lunarfyr3
|
409
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geeziap
|
409
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geeziap
|
410
410
|
:body: I like that, much more readable than reduce!
|
411
411
|
:replies: []
|
412
412
|
- :author: jschulenklopper
|
413
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecr4qd
|
413
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecr4qd
|
414
414
|
:body: |-
|
415
415
|
My solution, using some other Ruby language features.
|
416
416
|
|
@@ -435,7 +435,7 @@
|
|
435
435
|
```
|
436
436
|
:replies: []
|
437
437
|
- :author: jtgorn
|
438
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecq4a4
|
438
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gecq4a4
|
439
439
|
:body: |-
|
440
440
|
Ruby
|
441
441
|
|
@@ -457,11 +457,11 @@
|
|
457
457
|
```
|
458
458
|
:replies:
|
459
459
|
- :author: jura0011
|
460
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gectl55
|
460
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gectl55
|
461
461
|
:body: I like the `(min..max) === pwd.count(ch)`, better than my solution.
|
462
462
|
:replies: []
|
463
463
|
- :author: DropkickFish
|
464
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged1xbp
|
464
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/ged1xbp
|
465
465
|
:body: |-
|
466
466
|
Ruby. Not the best, but a quick one before work. Hopefully, I'll get chance to improve it and try pt 2 this evening. I need to go back and look at docs for better handling file inputs. Looking forward to seeing what wonderful new string/array/whatever message I learn from other people today
|
467
467
|
|
@@ -488,7 +488,7 @@
|
|
488
488
|
```
|
489
489
|
:replies:
|
490
490
|
- :author: DropkickFish
|
491
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geecawt
|
491
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geecawt
|
492
492
|
:body: |-
|
493
493
|
Ruby Pt 2 - did this after work and checked other solutions. I couldn't for the life of me think how best to reduce the size and run time, but then checked other answers and now I know `.captures` exists and there might be a better way to read the input amongst other things.
|
494
494
|
|
@@ -519,7 +519,7 @@
|
|
519
519
|
```
|
520
520
|
:replies: []
|
521
521
|
- :author: odlp
|
522
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gedbp0i
|
522
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gedbp0i
|
523
523
|
:body: |-
|
524
524
|
[Ruby](https://github.com/odlp/advent-of-code-2020/blob/main/day-2/passwords.rb):
|
525
525
|
|
@@ -550,7 +550,7 @@
|
|
550
550
|
```
|
551
551
|
:replies: []
|
552
552
|
- :author: Unihedron
|
553
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gec9ugj
|
553
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gec9ugj
|
554
554
|
:body: |-
|
555
555
|
Ruby. Messed up my interpreter settings and lots lots of minutes fixing that :'(
|
556
556
|
|
@@ -565,7 +565,7 @@
|
|
565
565
|
```
|
566
566
|
:replies: []
|
567
567
|
- :author: jeffers0n
|
568
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geem9m8
|
568
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/geem9m8
|
569
569
|
:body: |-
|
570
570
|
Ruby :)
|
571
571
|
|
@@ -633,7 +633,7 @@
|
|
633
633
|
```
|
634
634
|
:replies: []
|
635
635
|
- :author: OutofPlaceStuff
|
636
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gef04ld
|
636
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k52psu/2020_day_02_solutions/gef04ld
|
637
637
|
:body: |-
|
638
638
|
Done part 1 in Ruby and in Python. Python is my "native" language. I'm just now picking up Ruby for a potential job. Always open to feedback.
|
639
639
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
- :author: blafunke
|
3
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gesnj0d
|
3
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gesnj0d
|
4
4
|
:body: |-
|
5
5
|
Ruby
|
6
6
|
|
@@ -27,7 +27,7 @@
|
|
27
27
|
```
|
28
28
|
:replies: []
|
29
29
|
- :author: Krakhan
|
30
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geojvcd
|
30
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geojvcd
|
31
31
|
:body: |-
|
32
32
|
**Ruby**
|
33
33
|
|
@@ -62,7 +62,7 @@
|
|
62
62
|
```
|
63
63
|
:replies: []
|
64
64
|
- :author: odlp
|
65
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gehbw6b
|
65
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gehbw6b
|
66
66
|
:body: |-
|
67
67
|
My solution in [Ruby](https://github.com/odlp/advent-of-code-2020/blob/main/day-3/path.rb):
|
68
68
|
|
@@ -96,7 +96,7 @@
|
|
96
96
|
```
|
97
97
|
:replies: []
|
98
98
|
- :author: Karl_Marxxx
|
99
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geiu43e
|
99
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geiu43e
|
100
100
|
:body: |-
|
101
101
|
Ruby
|
102
102
|
|
@@ -127,7 +127,7 @@
|
|
127
127
|
```
|
128
128
|
:replies: []
|
129
129
|
- :author: Piggelinmannen
|
130
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegu4yf
|
130
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegu4yf
|
131
131
|
:body: |-
|
132
132
|
Kind of dirty ruby solution...
|
133
133
|
|
@@ -152,7 +152,7 @@
|
|
152
152
|
```
|
153
153
|
:replies: []
|
154
154
|
- :author: CodeIsTheEnd
|
155
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegzjz1
|
155
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegzjz1
|
156
156
|
:body: |-
|
157
157
|
**Ruby:** 3:52/6:31, 345/279
|
158
158
|
|
@@ -163,7 +163,7 @@
|
|
163
163
|
I'll be streaming every day on [Twitch](https://twitch.tv/codeistheend).
|
164
164
|
:replies: []
|
165
165
|
- :author: DropkickFish
|
166
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gehbt8x
|
166
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gehbt8x
|
167
167
|
:body: |-
|
168
168
|
Ruby part 1, I'll do part 2 after work
|
169
169
|
|
@@ -189,7 +189,7 @@
|
|
189
189
|
```
|
190
190
|
:replies: []
|
191
191
|
- :author: jeffers0n
|
192
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gehtsaw
|
192
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gehtsaw
|
193
193
|
:body: |-
|
194
194
|
My solution in Ruby. It's a little sloppy but it got the job done.
|
195
195
|
|
@@ -235,7 +235,7 @@
|
|
235
235
|
```
|
236
236
|
:replies: []
|
237
237
|
- :author: DropkickFish
|
238
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geigsid
|
238
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geigsid
|
239
239
|
:body: |-
|
240
240
|
Ruby Pt 2, bad day edition. Silver lining: Looking at other solutions it looks like I should learn more about matrices and how to traverse them. One thing I'm loving about Advent of Code is I'm learning a lot more about gaps in my knowledge that I'd probably not have encountered in my own projects.
|
241
241
|
|
@@ -274,7 +274,7 @@
|
|
274
274
|
```
|
275
275
|
:replies: []
|
276
276
|
- :author: nata79
|
277
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gej2w5a
|
277
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gej2w5a
|
278
278
|
:body: |-
|
279
279
|
**Ruby**
|
280
280
|
|
@@ -308,7 +308,7 @@
|
|
308
308
|
```
|
309
309
|
:replies: []
|
310
310
|
- :author: readyready15728
|
311
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gehpi47
|
311
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gehpi47
|
312
312
|
:body: |-
|
313
313
|
A lot of solutions seem needlessly complex. Here's how I did it in Ruby:
|
314
314
|
|
@@ -332,7 +332,7 @@
|
|
332
332
|
```
|
333
333
|
:replies: []
|
334
334
|
- :author: frontpageminus
|
335
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegiesj
|
335
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegiesj
|
336
336
|
:body: |-
|
337
337
|
Ruby, 81/104. I wasn't sure if this code would have an off-by-one error when I submitted the answers, but I guess it worked.
|
338
338
|
|
@@ -365,7 +365,7 @@
|
|
365
365
|
```
|
366
366
|
:replies: []
|
367
367
|
- :author: Sharparam
|
368
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegk1u6
|
368
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegk1u6
|
369
369
|
:body: |-
|
370
370
|
### [Ruby (1525/1057)](https://github.com/Sharparam/advent-of-code/blob/master/2020/day3/solution.rb)
|
371
371
|
|
@@ -388,7 +388,7 @@
|
|
388
388
|
```
|
389
389
|
:replies: []
|
390
390
|
- :author: qaisjp
|
391
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegk33c
|
391
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegk33c
|
392
392
|
:body: |-
|
393
393
|
# Ruby
|
394
394
|
|
@@ -440,7 +440,7 @@
|
|
440
440
|
```
|
441
441
|
:replies: []
|
442
442
|
- :author: ni3t
|
443
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegkvqj
|
443
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/gegkvqj
|
444
444
|
:body: |-
|
445
445
|
# Ruby
|
446
446
|
|
@@ -459,11 +459,11 @@
|
|
459
459
|
```
|
460
460
|
:replies: []
|
461
461
|
- :author: chaelcodes
|
462
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geglwgo
|
462
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geglwgo
|
463
463
|
:body: Ruby https://github.com/ChaelCodes/Advent-of-Code-2020/pull/4
|
464
464
|
:replies: []
|
465
465
|
- :author: maccosmo
|
466
|
-
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geh8qkj
|
466
|
+
:url: https://www.reddit.com/r/adventofcode/comments/k5qsrk/2020_day_03_solutions/geh8qkj
|
467
467
|
:body: |-
|
468
468
|
My solution in Ruby
|
469
469
|
|