From ff1745df3a74baab36c85e2688da1e08bdaef432 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 7 Dec 2025 22:44:24 -0500 Subject: [PATCH] wip --- day07/run.pl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/day07/run.pl b/day07/run.pl index 928794a..5cadc81 100755 --- a/day07/run.pl +++ b/day07/run.pl @@ -49,13 +49,13 @@ for(my $y=0; $y<@lines; $y++) { } my $ends = 0; -my $numworkers = 16; +my $numworkers = $ARGV[0] || 16; my $queue = Thread::Queue->new(); my @threads; $queue->enqueue($startpos); for(my $i=0; $i<$numworkers; $i++) { - push @threads, threads->create(\&process); + push @threads, threads->create(\&process, $i); } foreach my $thread (@threads) { @@ -66,8 +66,12 @@ foreach my $thread (@threads) { print "$ends total ends\n"; sub process { + my $threadid=shift(@_); my $ends = 0; while(my $pos=$queue->dequeue_timed(5)) { + if($threadid == 0) { + print $queue->pending() . " pending\n"; + } my($x,$y)=@$pos; for(;;) { @@ -77,8 +81,9 @@ sub process { last; } elsif($rows[$x][$y] eq '^') { $queue->enqueue([$x-1, $y]); - $queue->enqueue([$x+1, $y]); - last; + $x++; + #$queue->enqueue([$x+1, $y]); + #last; } } }