APL
I finally managed to make use of ⍣ :D
input←⊃⎕NGET'inputs/day9.txt'1
p←{⍎('¯'@((⍸'-'∘=)⍵))⍵}¨input
f←({⍵⍪⊂2-⍨/⊃¯1↑⍵}⍣{∧/0=⊃¯1↑⍺})
⎕←+/{+/⊢/¨f⊂⍵}¨p ⍝ part 1
⎕←+/{-/⊣/¨f⊂⍵}¨p ⍝ part 2
I finally managed to make use of ⍣ :D
input←⊃⎕NGET'inputs/day9.txt'1
p←{⍎('¯'@((⍸'-'∘=)⍵))⍵}¨input
f←({⍵⍪⊂2-⍨/⊃¯1↑⍵}⍣{∧/0=⊃¯1↑⍺})
⎕←+/{+/⊢/¨f⊂⍵}¨p ⍝ part 1
⎕←+/{-/⊣/¨f⊂⍵}¨p ⍝ part 2
I’m using this year’s AoC to learn (Dyalog) APL, so this is most likely a pretty terrible solutions. I would’ve liked to use ⍣
instead of of my imitation of a while loop with a recursive function, but I couldn’t figure out how to get to the number of iterations ⍣ performed to arrive at the destination. If someone here knows how to do that (or has other suggestions for improvement) I’m open for suggestions.
⎕IO ← 0 ⍝ use 0-based indexes
I←⌷⍨∘⊃⍨⍤0 99 ⍝ "sane" indexing
⎕PP←17 ⍝ print integers with up to 17 significant digits without use of scientific notation
input←⊃⎕NGET'inputs/day8.txt'1
instructions←⊃input
p←↑{0 2 4 I{6⍴⎕CSV⍠'Widths'(3 4 3 2 3 1)⊢⍵'S'1}⍵}¨ 2↓input
nodes←,1↑[1]p
L←(⍳⍴nodes) ∘.{nodes[⍺]≡⍵ 1 ⌷p} ⍳⍴nodes
R←(⍳⍴nodes) ∘.{nodes[⍺]≡⍵ 2 ⌷p} ⍳⍴nodes
S←(⊃(+.×)/{'R'≡⍵:R ⋄ ⍵≡'L':L}¨⌽instructions)
⎕←(≢instructions) × {⍺←0 ⋄ ⍵[⍸'ZZZ'∘≡¨nodes]: ⍺ ⋄ ⍺+1 ∇ S+.×⍵}'AAA'∘≡¨nodes ⍝ part 1
⎕←∧/(≢instructions) × {⍺←0 ⋄ 0≡+/⍵[⍸~('Z'∘=⊢/)¨nodes]: ⍺ ⋄ ⍺+1 ∇ S+.×⍵}¨{(⍳≢nodes)=⍵}¨⍸('A'∘=⊢/)¨nodes ⍝ part 2
I haven’t heard of Uiua before, but I can read some things :D I like the idea of rotating the vector instead of manually padding it with the required number of leading zeroes!
I’m using this years’ AoC to learn (Dyalog) APL, so this is probably terrible code. I’m happy to receive pointers for improvement, particularly if there is a way to write the same logic with tacit functions or inner/outer products that I missed.
input←⊃⎕NGET'inputs/day4.txt'1
num_matches←'Card [ \d]+: ([ 0-9]+) \| ([ 0-9]+)'⎕S{≢↑∩/0~⍨¨{,⎕CSV⍠'Separator' ' '⊢⍵'S'3}¨⍵.(1↓Lengths↑¨Offsets↓¨⊂Block)} input
⎕←+/2*1-⍨0~⍨num_matches ⍝ part 1
⎕←+/{⍺←0 ⋄ ⍺=≢⍵:⍵ ⋄ (⍺+1)∇⍵ + (≢⍵)↑∊((⍺+1)⍴0)(num_matches[⍺]⍴⍵[⍺])((≢⍵)⍴0)}(≢num_matches)⍴1 ⍝ part 2
I’m aware that the person is disabled, but they explicitly stated in their comment that “there’s currently no reason for someone to switch to public transport” and that “all this is going to do is annoy and upset people”. That to me implied that they didn’t think of cycling as an alternative to driving a car at all, which is understandable given that they probably can’t cycle. So all I did was offer the perspective of someone that does cycle and has to ride on busy streets because there are no bike lanes in hope that they’d appreciate that perspective just as much as I’d appreciate someone giving me their perspective when I’m missing something due to my personal circumstances.
I agree that there need to be alternatives to cycling in place for those that can’t or don’t want to cycle. Its all about capacity planning, though. If you assume that 20% of your population will use bikes for short to medium distances you’ll have to plan with much more frequent and larger busses or even consider building subway or train infrastructure to get all these people to their destination than if you assume that 70%-80% will use their bikes. So as a transportation planner you’ll need to make a judgement call on how you want the future of transportation to look like in the area you’re responsible for, but I don’t think the choice to make biking the backbone of transportation is necessarily to the detriment of everyone else. To the contrary, the public transport might be less crowded if most people use their bikes, so that for example folks in wheelchairs or those with trouble walking have it easier to get on and off.
I’m not from Wales, so I don’t know how good the cycling infrastructure is there. But for me this change would make me feel much safer cycling on busy city streets. So this might encourage a few people to take their bike instead of their car.
The way @Oka described it the fob would only change the code if the car sends a new code. So if you’re out of range the fob would send the same code again on the next press.
However, if the dealership can reset the fob and car then in due time so will any criminal, either by acquiring the necessary hard- and software from a dealership going out of business or someone reverse-engineering it.
I was forced to stop using WhatsApp a while back because they simply stopped supporting my phone, and I sure as hell wasn’t going to buy a new one just to use WhatsApp. I came to the conclusion that anyone that doesn’t bother reaching out e.g. via SMS isn’t a real friend anyway, and indeed it hasn’t affected me personally much. There are some people I’ve lost contact with completely now, but we didn’t have proper conversations when I still had WhatsApp anyway, so not much was lost.
Ja da wird die Dunkelziffer recht hoch sein. Ich habe seit mehreren Jahren einen Organspendeausweis aus Plastik (den konnte man frueher kostenlos online bestellen), aber ich hatte noch nie von dem Online-Register gehoert und bin dementsprechend da auch nicht eingetragen.