← Back to challenges

Count 5s and Win

PythonHardalgorithmsarrays

Instructions

Arun is obsessed with primes, especially five. He considers a number to be luckiest if it has the highest number of five in it. If two numbers have the same frequency of five, Arun considers the larger of them to be luckiest, and if there is no five in any number, the first given number is considered luckiest. Help him choose the luckiest number.

Examples

get_luckiest([5, 12, 55, 11]) ➞ 55

get_luckiest([5, 12, -55,  11]) ➞ -55

get_luckiest([515, 1255, -55,  1]) ➞ 1255

get_luckiest([44, 12, 7, 40]) ➞ 44

Notes

Return None if given an empty list.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.