DEV Community

Discussion on: Daily Challenge #16 - Number of People on the Bus

Collapse
 
choroba profile image
E. Choroba • Edited
#! /usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use List::Util qw{ sum };

sub bus { sum(map $_->[0] - $_->[1], @_) }

use Test::More tests => 1;
my @people = ([10, 0], [5, 3], [12, 1], [1, 3], [0, 3], [1, 7]);
is bus(@people), 12;

BTW, it seems today's post didn't make it into the series.
Update: It's been fixed.