#!/usr/bin/perlusewarnings;usestrict;useList::Utilqw{ sum };useList::MoreUtilsqw{ part };sub beggars{my($money,$number_of_beggars)=@_;my$i=0;[mapsum(@$_),part{$i++%$number_of_beggars}@$money];}useTest::Moretests=>2;is_deeplybeggars([1,2,3,4,5],2),[9,6];is_deeplybeggars([1,2,3,4,5],3),[5,7,3];
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Going functional in Perl: