We don't bite newbies here... much | |
PerlMonks |
Re: Lottery using arraysby Athanasius (Archbishop) |
on Sep 27, 2012 at 04:19 UTC ( [id://995924]=note: print w/replies, xml ) | Need Help?? |
Hello perlguru22, Since this looks like a homework assignment, I won’t solve it for you, but I will give you a few pointers:
So, your solution should begin as follows:
At this point, you have to sort the frequencies in descending order. The problem specification says: You must then manually sort the frequency array in descending order and when swapping values... The word “manually”, together with the reference to “swapping values”, rules out any recourse to Perl’s sort function. You will no doubt have been given one or more sorting algorithms in your coursework (for example, bubble sort, selection sort, quicksort — see Sorting_algorithm), and your task is to implement one of these to sort both @freq and @num in parallel. Hint: The swapping part of your code should be something like this:
Hope that helps, Athanasius <°(((>< contra mundum
In Section
Seekers of Perl Wisdom
|
|