Perl Weekly Challenge 040
Final Perl Weekly Challenge of 2019
What I Did
- Wrote a function display() which takes as input any number of arrays references.
- 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.
- 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.
What I Did
- Set up some Readonly arrays to hold the example data.
- Initialize @sorted to be the original array. Line 12
- Obtain the specified elements and sort them. Line 13
- Sort the indices. Line 14.
- Put the sorted values in the right locations in @sorted.
- 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!