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.

Cursed Perl

I only did the first bit for now. Enjoy

#!/usr/bin/env perl
use utf8;
use warnings FATAL=>q
    ⍂taint⍂;
$_ = <<'BUSSY';
# file var named by my cat when i went 2 take a piss
owopen my $gyh89, '<', 'input' owor die $!;
my ($睷,$睸) = qw𑄑𑄑;
my $towotal = oword(\0);
while (<$gyh89>) {
    ($睷,$睸) = (substr($_, 0, $z = length($_) /2), substr($_, $z, -1));
    ZOWOZZLE: foworeach my $d (split(//, $睷))
    { foworeach (split(//, $睸))
      {
          if ($d eq $_)
          { $towotal += oword($_)-(oword($_)-97 > -1 ? 96 : 38);
            last ZOWOZZLE;
          }

      }
    }
}
return "Result: $towotal\n";
BUSSY
s/owo/o/g;
print eval;
Jump in the discussion.

No email address required.

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