aoc2021

Advent of Code 2021 solutions in Perl.
git clone git://git.samirparikh.com/aoc2021
Log | Files | Refs | README

commit 2a99e78ef9061493fc5ef7a8161d7cd644f6edeb
parent 0105cf149e3c0b2f38b16a41ee3290d5bfd17231
Author: Samir Parikh <noreply@samirparikh.com>
Date:   Tue,  7 Dec 2021 13:49:45 +0000

remove files

Diffstat:
Dday04-oantolin.pl | 27---------------------------
Dday04-smylers.pl | 20--------------------
2 files changed, 0 insertions(+), 47 deletions(-)

diff --git a/day04-oantolin.pl b/day04-oantolin.pl @@ -1,27 +0,0 @@ -#!/usr/bin/env perl - -#use strict; -#use warnings; -use List::Util qw(none sum); -my @numbers = split /,/, <>; -$/ = ""; # read a paragraph at a time -my @cards = map {[map {[split " "]} split /\n/]} <>; - -my @scores; -foreach my $n (@numbers) { - foreach my $c (@cards) { - foreach my $i (0..4) { - foreach my $j (0..4) { - if ($c->[$i][$j] == $n) { - delete $c->[$i][$j]; - if (none {defined $c->[$_][$j]} 0..4 or - none {defined $c->[$i][$_]} 0..4) { - push @scores, $n * sum map {$c->[$_/5][$_%5]} (0..24); - delete $c->[$_] for 0..4; - } - } - } - } - } -} -printf "Part 1: %d. Part 2: %d.", $scores[0], $scores[-1]; diff --git a/day04-smylers.pl b/day04-smylers.pl @@ -1,20 +0,0 @@ -#!/usr/bin/env perl - -# Day 4 both parts, by Smylers - -use v5.14; -use warnings; -use List::AllUtils qw<sum>; - -$/ = ''; -my ($calls, @board, $winner) = <>; -while ($calls =~ /(\d+)/g) -{ - my $called = sprintf '%2d', $1; - @board = grep - { - s/$called\b/##/; - !/^[# ]+$|#(?:.{14}#){4}/ms - or do { say $called * sum /(\d+)/g if !$winner++ || @board == 1; 0 } - } @board; -}