How to find the correct min / max values ​​of a list in Perl 6

New to Perl6, trying to figure out what I'm doing wrong here. The problem is a simple checksum that takes into account the max and min values ​​for each line in csv

The return values ​​max and min are completely erroneous. For the first line in csv, it returns max as 71, and min is 104, which is incorrect.

Here's the link in the repo for the link, and link with the corresponding problem.

#!/usr/bin/env perl6

use Text::CSV;

sub checksum {
    my $sum = 0;
    my @data = csv(in => "input.csv");
    for @data -> @value {
        $sum += (max @value) - (min @value);
    }
    say $sum;
}

checksum
+4
source share
1 answer

, , CSV , . min max , max("4", "10") - 4, max("04", "10") - 10. , Numeric (int, ..), min/max:

@input.map(*.Numeric).max

min max, , :

@input.max(*.Numeric)

, , , . : +* { +$_ } " X ", : .Numeric.

+12

Source: https://habr.com/ru/post/1690220/


All Articles