Created
February 26, 2018 03:15
-
-
Save thomastay/36e5303c5b133f6afc421da4788fb489 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/python3 | |
from itertools import permutations | |
#This program checks that there are four and only four numbers in their natural position | |
def checkPmt(pmt, numInPosition = 4): | |
#pmt is a tuple of length n | |
currInPosition = 0; | |
for i,k in enumerate(pmt): | |
if (i+1 == k): currInPosition += 1; | |
return (currInPosition == numInPosition); | |
def main(): | |
for pmt in permutations(range(1,9),8): | |
if (checkPmt(pmt,4)): | |
print (pmt); | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment