diff options
Diffstat (limited to 'challenge-258/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-258/eric-cheung/python/ch-2.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-258/eric-cheung/python/ch-2.py b/challenge-258/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..a6088a474b --- /dev/null +++ b/challenge-258/eric-cheung/python/ch-2.py @@ -0,0 +1,15 @@ +
+## Example 1
+## arrInt = [2, 5, 9, 11, 3]
+## nInput = 1
+
+## Example 2
+## arrInt = [2, 5, 9, 11, 3]
+## nInput = 2
+
+## Example 3
+arrInt = [2, 5, 9, 11, 3]
+nInput = 0
+
+arrOutput = [elemLoop for nIndx, elemLoop in enumerate(arrInt) if bin(nIndx)[2:].count("1") == nInput]
+print (sum(arrOutput))
|
