advent2022

Advent of Code 2022 Solutions
git clone https://todayiwilllaunchmyinfantsonintoorbit.com/advent2022.git
Log | Files | Refs

2a.pl (574B)


      1 #!/usr/bin/perl
      2 
      3 my $score = 0;
      4 while (<>) {
      5     chomp;
      6     /^([ABC]) ([XYZ])$/ || die "Fuck!";
      7     (my $them, $me) = (ord($1) - 64, ord($2) - 87);
      8     $score += $me;
      9     if ((($them > $me) && !($me == 1 && $them == 3))|| ($them == 1 && $me == 3)) {
     10         # Nothing!
     11         print "Them\n";
     12     } elsif (($me > $them) || ($me == 1 && $them == 3)) {
     13         print "Me\n";
     14         $score += 6;
     15     } elsif ($me == $them) {
     16         print "Tie\n";
     17         $score += 3;
     18     } else {
     19         print "What the fuck\n";
     20     }
     21     print "Score is now $score\n";
     22 }
     23 print "$score\n";