From 348adb792a21a38fdafbd4977e18ca4b29881ae5 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 3 Oct 2023 12:33:39 +0100 Subject: - Added solutions by Eric Cheok-Yin. - Added solutions by Robert DiCicco. - Added solutions by PokGoPun. - Added solutions by rcmlz. - Added solutions by David Ferrne. - Added solutions by W. Luis Mochan. - Added solutions by Peter Meszaros. - Added solutions by E. Choroba. - Added solutions by Luca Ferrari. - Added solutions by Thomas Kohler. --- challenge-237/eric-cheung/python/ch-2.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 challenge-237/eric-cheung/python/ch-2.py (limited to 'challenge-237/eric-cheung/python/ch-2.py') diff --git a/challenge-237/eric-cheung/python/ch-2.py b/challenge-237/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..16e420e9a2 --- /dev/null +++ b/challenge-237/eric-cheung/python/ch-2.py @@ -0,0 +1,14 @@ + +from itertools import permutations + +def GetGreatness (arrNum, arrPerm): + return len([nIndx for nIndx in range(len(arrNum)) if arrNum[nIndx] < arrPerm[nIndx]]) + +## arrNumList = [1, 3, 5, 2, 1, 3, 1] ## Example 1 +arrNumList = [1, 2, 3, 4] ## Example 2 + +arrPermList = permutations(arrNumList) + +arrGreatness = [GetGreatness (arrNumList, arrPermLoop) for arrPermLoop in list(arrPermList)] + +print (max(arrGreatness)) -- cgit