Last active
December 1, 2021 03:31
-
-
Save AyaanZaveri/0c4e8c6ebf15d1aea588450d9f0d8a00 to your computer and use it in GitHub Desktop.
Math Extension #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from itertools import permutations | |
nums = [2124, 1984, 1724, 2344, 2074, 1632] | |
combination = permutations(nums, 4) | |
for i in combination: | |
sumofnums = i[0] + i[1] + i[2] + i[3] | |
i = list(i) | |
if sumofnums / 4 == 2021: | |
print(f"Numbers that have a mean of 2021: {i}.\n") | |
for j in range(0,6): | |
in_i = nums[j] in i | |
print(f"What numbers are in and what numbers are out: {in_i} {nums[j]}.\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Numbers that have a mean of 2021: [2124, 1984, 2344, 1632]. | |
What numbers are in and what numbers are out: True 2124. | |
What numbers are in and what numbers are out: True 1984. | |
What numbers are in and what numbers are out: False 1724. | |
What numbers are in and what numbers are out: True 2344. | |
What numbers are in and what numbers are out: False 2074. | |
What numbers are in and what numbers are out: True 1632. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment