advent of code day 3: i might be r-slurred edition

idk how to do multi line spoilers lol



letters = ['','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

total_score = 0

team = []

for line in open("input.txt"):
    team.append(line.strip())

for i in range(2, len(team), 3):
    for letter in team[i]:
        if letter in team[i-2] and letter in team[i-1]:
            total_score += letters.index(letter)
            break

print(total_score)

some real caveman shit but it works

80
Jump in the discussion.

No email address required.

First 3 days in GNU APL:

⍝ ~~~ Day 1 ~~~ ⍝

r←⊢⎕FIO[49] 'day1raw.txt'
e←+/¨⍎¨¨r⊂⍨,⍉⊃0≠⍴¨r ⋄ ⌈/e ⋄ +/3↑e⌷⍨⊂⍒e

⍝ ~~~ Day 2 ~~~ ⍝

k←⊂(,'ABC'∘.{⍺' '⍵}'XYZ')⍳⊢⎕FIO[49]'2'
+/k⌷4 8 3 1 5 9 7 2 6 ⋄ +/k⌷3 4 8 1 5 9 2 6 7

⍝ ~~~ Day 3 ~~~ ⍝

r←⊢⎕FIO[49] 'day3raw.txt'
p←'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+/p⍳↑¨({⍵↑⍨2÷⍨⍴⍵}¨r)∩¨{⍵↑⍨2÷⍨⍴⍵}¨⌽¨r ⋄ +/p⍳↑¨⊃∩/¨r⊂⍨3/⍳↑3÷⍨⍴r
Jump in the discussion.

No email address required.

How the FRICK do you and the K guy who posted earlier understand this shit?!

Jump in the discussion.

No email address required.

Just for you, day 3:

raw←⊢⎕FIO[49] 'day3raw.txt'     ⍝ Text file as array of strings.
priorities←'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

first←{⍵↑⍨2÷⍨⍴⍵}¨raw            ⍝ First half of each string.
last←{⍵↑⍨2÷⍨⍴⍵}¨⌽¨raw          ⍝ Last half of each string (flips the string and applies the same function).
both←last∩¨first                ⍝ Intersection ∩ to find char in both string halves.
a←+/priorities⍳↑¨both           ⍝ Map each char to index in priorities, find sum.

mask←3/⍳↑3÷⍨⍴raw                ⍝ Array 1 1 1 2 2 2 3 3 3 ... 100 100 100.
groups←mask⊂raw                 ⍝ Split raw into groups of 3 using mask array.
badges←↑¨⊃∩/¨groups             ⍝ Intersection to find char common to all group members.
b←+/priorities⍳badges           ⍝ Map each char to index in priorities, find sum.

a b                             ⍝ Print answers.

Evaluation is simple (right to left, no priority BS) so writing one-liners comes naturally. Much easier to keep track of than half the answers itt triggering longpostbot.

Jump in the discussion.

No email address required.

genuinely keep yourself safe

Jump in the discussion.

No email address required.

What the god darn heck is going on here

Also whatever this is someone do it in Haskell so I spend five hours looking at it just to get more and more and more pissed off at having the wrong flavour of autism

Jump in the discussion.

No email address required.

:marseyrandom:

Jump in the discussion.

No email address required.

Sigh

There are people in the world who would look at that and say how beautiful and elegant it is

It just makes me seethe

I really don't know how they manage to visualise it all in their heads without getting lost

Jump in the discussion.

No email address required.

It's similar to people who think Common Lisp is pretty. It's really just a very acquired taste, and IMO i doubt many people these days really think it looks pretty and just fake it.

Lisp looks fricking ugly as heck lol, and it's unusable without a good text editor (Emacs usually), which, in my honest opinion, is a sign of an imperfect language if you need another tool to even write it effectively. Yet I see lots of neurodivergents saying it's like the Mona Lisa of programming languages (its functionally cool in theory, but it still looks fricking ugly)

Jump in the discussion.

No email address required.

:marseyrandom:

Jump in the discussion.

No email address required.

sexp lole! xD xP shits all over the carpet

Jump in the discussion.

No email address required.

>good text editor (Emacs usually)

Nice bait :marseyclapping:

Jump in the discussion.

No email address required.

it is a remarkable text editor :marseyhappytears:

Jump in the discussion.

No email address required.

I had to learn it for one of my classes it was so gay and Jewish

Jump in the discussion.

No email address required.

It isn't one I've encountered. I have a degree in Computer Science but I'm not rabidly enthusiastic about the subject enough to have tried every single language there is like some people seem to do.

To me, it's like... I'll pick from the box that will let me get the job done in the simplest and most effective manner. Most of the time that's going to be whatever's currently most popular in the sector you're targeting because that's where you'll find the most supportive/active community and the largest variety of libraries and examples. When you're pushing into performance limited areas or going from a prototype to something business you might want to refactor for something more performant or more optimised for that specific type of processing.

I don't really get these people who always want to be working with the absolute bleeding edge language and who are always evangelizing it. It just seems so exhausting.

Jump in the discussion.

No email address required.

:#marseysus: :#chadbasedcapy:

Jump in the discussion.

No email address required.

what the frick is ⍝

Jump in the discussion.

No email address required.

sus

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.