adventofcode/2018/07/sol1.pl

23 lines
316 B
Perl
Raw Normal View History

2018-12-10 15:32:54 +00:00
use 5.20.0;
use warnings;
use experimental qw/
signatures
postderef
/;
use Graph::Directed;
my $g = Graph::Directed->new;
while(<>) {
/Step (.).*before step (.)/;
$g->add_edge( $1 => $2 );
}
while( my @x = sort $g->predecessorless_vertices ) {
print $x[0];
$g->delete_vertex($x[0]);
}