Perl (yay)

This commit is contained in:
Bill Rossi 2023-12-18 09:46:31 -05:00
parent 14db0c5ff0
commit 24f4e57b2b
2 changed files with 25 additions and 0 deletions

19
perl/2015/1/problem.pl Normal file
View File

@ -0,0 +1,19 @@
open(FILE, "<", "../data/2015/1/input.txt") or die $!;
my $read, $steps, $floor = 0;
while (read FILE, $char, 1) {
$floor += 1 if $char eq "(";
$floor -= 1 if $char eq ")";
}
print "Part 1: $floor\n";
seek FILE, 0, 0;
$floor = $steps = 0;
while (read FILE, $char, 1) {
$floor += 1 if $char eq "(";
$floor -= 1 if $char eq ")";
$steps++;
last if $floor < 0;
}
print "Part 2: $steps\n";

6
perl/bin/run Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
year=$1
day=$2
time perl ./$year/$day/problem.pl