diff options
| author | irifkin <ianrifkin@ianrifkin.com> | 2023-11-29 15:56:36 -0500 |
|---|---|---|
| committer | irifkin <ianrifkin@ianrifkin.com> | 2023-11-29 15:56:36 -0500 |
| commit | 25917d1892085b04f55d9da828f6be65421b27df (patch) | |
| tree | 9f5dbb1e7e20bf5c34a5cff0aa399b93d22634c0 | |
| parent | e678c347452eaab29ee620d6699bd09f979d5a3e (diff) | |
| download | perlweeklychallenge-club-25917d1892085b04f55d9da828f6be65421b27df.tar.gz perlweeklychallenge-club-25917d1892085b04f55d9da828f6be65421b27df.tar.bz2 perlweeklychallenge-club-25917d1892085b04f55d9da828f6be65421b27df.zip | |
readme title and formatting
| -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 |
