all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
22
Task/Text-processing-2/Perl-6/text-processing-2-1.pl6
Normal file
22
Task/Text-processing-2/Perl-6/text-processing-2-1.pl6
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
my $fields = 49;
|
||||
|
||||
my ($good-records, %dates) = 0;
|
||||
for 1 .. * Z $*IN.lines -> $line, $s {
|
||||
my @fs = split /\s+/, $s;
|
||||
@fs == $fields or die "$line: Bad number of fields";
|
||||
given shift @fs {
|
||||
m/\d**4 \- \d**2 \- \d**2/ or die "$line: Bad date format";
|
||||
++%dates{$_};
|
||||
}
|
||||
my $all-flags-okay = True;
|
||||
for @fs -> $val, $flag {
|
||||
$val ~~ /\d+ \. \d+/ or die "$line: Bad value format";
|
||||
$flag ~~ /^ \-? \d+/ or die "$line: Bad flag format";
|
||||
$flag < 1 and $all-flags-okay = False;
|
||||
}
|
||||
$all-flags-okay and ++$good-records;
|
||||
}
|
||||
|
||||
say 'Good records: ', $good-records;
|
||||
say 'Repeated timestamps:';
|
||||
say ' ', $_ for grep { %dates{$_} > 1 }, sort keys %dates;
|
||||
19
Task/Text-processing-2/Perl-6/text-processing-2-2.pl6
Normal file
19
Task/Text-processing-2/Perl-6/text-processing-2-2.pl6
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
my $good-records;
|
||||
my $line;
|
||||
my %dates;
|
||||
|
||||
for lines() {
|
||||
$line++;
|
||||
/ ^
|
||||
(\d ** 4 '-' \d\d '-' \d\d)
|
||||
[ \h+ \d+'.'\d+ \h+ ('-'?\d+) ] ** 24
|
||||
$ /
|
||||
or note "Bad format at line $line" and next;
|
||||
%dates.push: $0 => $line;
|
||||
$good-records++ if $1.all >= 1;
|
||||
}
|
||||
|
||||
say "$good-records good records out of $line total";
|
||||
|
||||
say 'Repeated timestamps (with line numbers):';
|
||||
.say for sort %dates.pairs.grep: *.value.elems > 1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue