The task title reminded me of the song Let's Dance to Joy Division . Oddly applicable lyrics for a blog about programming: "But I worked something out last night that changed this little boy's brain, a small piece of advice that took 22 years in the make, and I will break it for you now. Please learn from my mistakes." And who doesn't love a wombat?
Task Description
You are given a list and a non-negative integer, $n . Write a script to divide the given list into $n equal parts. Return -1 if $n is more than the size of the list.
Example 1
Input: @list = ( 1,2,3,4,5), $n = 2 Output: ((1,2,3), (4,5))
Enter fullscreen mode
Exit fullscreen mode
5 / 2 = 2 remainder 1.…