diff options
Diffstat (limited to 'challenge-237/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-237/eric-cheung/python/ch-2.py | 14 |
1 files changed, 14 insertions, 0 deletions
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))
|
