Posted By

apoz on 06/23/11


Tagged

perl contest tuenti


Versions (?)

Space separated values sum


 / Published in: Perl
 

Program that sums all the values (including big positive/negative integers)

  1. use strict;
  2. use warnings;
  3. use Math::BigInt;
  4.  
  5. while(<>)
  6. {
  7. s/^ +//g;
  8. my @values = split /\s+/;
  9. my $elemento;
  10. my $sum = Math::BigInt->new('0');
  11. foreach $elemento (@values)
  12. {
  13. $sum->badd(Math::BigInt->new($elemento));
  14. }
  15. print "$sum\n";
  16. $sum=0;
  17. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: apoz on June 23, 2011

This snippet solves Tuenti programming contest #1 test https://contest.tuenti.net/?id=1&m=Questions&func=index

Posted By: apoz on June 23, 2011

This snippet solves Tuenti programming contest #1 test https://contest.tuenti.net/?id=1&m=Questions&func=index

Posted By: apoz on June 23, 2011

This snippet solves Tuenti programming contest #1 test https://contest.tuenti.net/?id=1&m=Questions&func=index

You need to login to post a comment.