aboutsummaryrefslogtreecommitdiff
path: root/challenge-243/deadmarshal/perl/ch-2.pl
blob: 99efb965622b607f05d84b240900ca63b22e4d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env perl
use strict;
use warnings;
use Algorithm::Combinatorics qw(variations_with_repetition);

sub floor_sum{
  my $it = variations_with_repetition($_[0],2);
  my $sum = 0;
  while(my $c = $it->next){
    $sum += int($c->[0] / $c->[1]);
  }
  $sum
}

printf "%d\n",floor_sum([2,5,9]);
printf "%d\n",floor_sum([7,7,7,7,7,7,7]);