2021-06-04 10:55:59 +02:00
|
|
|
#!usr/bin/perl
|
2021-06-04 10:34:27 +02:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
my $file = 'input';
|
|
|
|
my $total = 0;
|
|
|
|
my $tmp;
|
|
|
|
open(FH, '<:encoding(UTF-8)', $file) or die $!;
|
|
|
|
|
|
|
|
print "Traitement de la première partie…\n";
|
|
|
|
|
|
|
|
while (<FH>) {
|
|
|
|
$tmp = eval $_;
|
|
|
|
chomp($_);
|
|
|
|
chomp($tmp);
|
|
|
|
$total = $total + length($_) - length($tmp);
|
|
|
|
}
|
|
|
|
|
2021-06-04 10:55:59 +02:00
|
|
|
print "Le total est : $total.\n";
|
|
|
|
seek FH, 0, 0;
|
|
|
|
$total = 0;
|
|
|
|
print "Traitement de la deuxième partie…\n";
|
|
|
|
|
|
|
|
while (<FH>) {
|
|
|
|
$tmp = $_;
|
|
|
|
$tmp =~ s/\\/\\\\/ig;
|
|
|
|
$tmp =~ s/"/\\"/ig;
|
|
|
|
chomp($tmp);
|
|
|
|
chomp($_);
|
|
|
|
$total = $total + length($tmp) + 2 - length($_);
|
|
|
|
}
|
2021-06-04 10:34:27 +02:00
|
|
|
|
|
|
|
print "Le total est : $total.\n";
|
2021-06-04 10:55:59 +02:00
|
|
|
close(FH);
|