Perl Weekly Challenge 040

Final Perl Weekly Challenge of 2019

Part 1

Sample Run output output

What I Did

  1. Wrote a function display() which takes as input any number of arrays references.
  2. In display(): Find the maximum array index (Line 13). In this example the arrays are all the same size but we do not assume that will always be the case.
  3. In display(): Loop over the arrays and print out the elements, separated by a tab. If an array does not have an element in that index, print an empty string.

Part 2

Sample Run output output

What I Did

  1. Set up some Readonly arrays to hold the example data.
  2. Initialize @sorted to be the original array. Line 12
  3. Obtain the specified elements and sort them. Line 13
  4. Sort the indices. Line 14.
  5. Put the sorted values in the right locations in @sorted.
  6. Print the now partially sorted array, as specified.


Thank you to Mohammad S. Anwar for creating and continuously organizing the Perl Weekly Challenge! The PWC began in early 2019 and it has provided a great mental outlet throughout this past year, especially during lengthy interminable conference calls at work! Besides just Perl and Raku I have even been inspired to occasionally submit solutions in C++. Other members have also submitted guest language solutions in Haskell, Python, and, most heroically of all, Postscript.

Also, quite noteworthy, the PWC has spawned a small resurgence in Perl specific blogs as each week participants describe and elaborate on their solutions.

Happy New Year to Team PWC! 

Comments for this post were locked by the author