-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_8_1.pl
More file actions
60 lines (48 loc) · 1 KB
/
task_8_1.pl
File metadata and controls
60 lines (48 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl
#===============================================================================
#
# FILE: task_8_1.pl
#
# USAGE: ./task_8_1.pl
#
# DESCRIPTION: https://adventofcode.com/2018/day/8
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Lubos Kolouch
# ORGANIZATION:
# VERSION: 1.0
# CREATED: 12/08/2018 12:36:27 PM
# REVISION: ---
#===============================================================================
use strict;
use warnings;
use autodie;
use 5.026;
use Data::Dumper;
my @arr;
my $result;
sub process_node {
my $child_nodes = shift @arr;
my $metadata = shift @arr;
for (1 .. $child_nodes) {
&process_node;
}
for (1 .. $metadata) {
my $m = shift @arr;
$result += $m;
}
return 1;
}
sub main {
open my $infile, '<', 'input8.txt';
my $str = <$infile>;
close $infile;
@arr = split / /, $str;
&process_node;
say $result;
return 1;
}
main;