Skip to content

Instantly share code, notes, and snippets.

@thomastay
Created February 26, 2018 03:15
Show Gist options
  • Save thomastay/36e5303c5b133f6afc421da4788fb489 to your computer and use it in GitHub Desktop.
Save thomastay/36e5303c5b133f6afc421da4788fb489 to your computer and use it in GitHub Desktop.
#!/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