Skip to content

Instantly share code, notes, and snippets.

@managedkaos
Created August 3, 2017 18:52
Embed
What would you like to do?
#!/usr/bin/env perl
# read the input
@data = split /\s+/, <STDIN>;
@data = sort @data;
map { $min += $_ } @data[0 .. ($#data - 1)];
map { $max += $_ } @data[1 .. $#data];
print "$min $max\n";
@managedkaos
Copy link
Author

managedkaos commented Aug 3, 2017

$ cat mini-max-sum.txt
1 2 3 4 5

$ ./mini-max-sum.pl < mini-max-sum.txt
10 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment