Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env perl
# read the input file
@input = <>;
# initialize the scores
@score = qw(0 0);
# split the input into arrays
foreach $i (0..1) {
@{ $data[$i] } = split(' ', $input[$i]);
}
# compare each element of the triplet
for $i (0..2) {
# increment the score of the larger element
$score[0]++ if ( $data[0][$i] > $data[1][$i] );
$score[1]++ if ( $data[1][$i] > $data[0][$i] );
}
# print the output
print join(" ",@score),"\n";
@managedkaos

This comment has been minimized.

Copy link
Owner Author

@managedkaos managedkaos commented Aug 2, 2017

$ cat alice-bob.txt
5 6 7
3 6 10

$ ./compare-the-triplets.pl < alice-bob.txt
1 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment