diff options
| -rw-r--r-- | challenge-245/ianrifkin/README.md | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/challenge-245/ianrifkin/README.md b/challenge-245/ianrifkin/README.md index d9c9e325ba..86cce400cb 100644 --- a/challenge-245/ianrifkin/README.md +++ b/challenge-245/ianrifkin/README.md @@ -1,7 +1,9 @@ -# Language popularity and largest of 3 +# I'm never last picked Challenge 245: https://theweeklychallenge.org/blog/perl-weekly-challenge-245/ +This week we have a task to sort an array based on another array and a task to calculate the largest number combination from a given input that is divisible by 3. + ## Task 1: Sort Language ``` @@ -22,10 +24,14 @@ Output: ('c++', 'java', 'haskell') My first instinct to solve this was to align the two arrays (lang and popularity) into a hash. While this made sense I quickly realized I would still have the step of sorting based on the keys. This should still have worked but since the arrays have the same indices I didn't really need to combine them into a hash. I sorted the popularity array and outputted the indices in sort order (not the values): -```my @pop_sort_idx = sort { $popularity[$a] <=> $popularity[$b] } 0 .. $#popularity;``` +``` +my @pop_sort_idx = sort { $popularity[$a] <=> $popularity[$b] } 0 .. $#popularity; +``` With that I return an array of the languages in sort order using the inputted langage array in the order of the sorted popularity: -```@lang[@pop_sort_idx];``` +``` +@lang[@pop_sort_idx]; +``` ## Task 2: Largest of Three |
