Created
January 15, 2014 17:14
-
-
Save bitoiu/8440288 to your computer and use it in GitHub Desktop.
prolog permutations of 1 and 2 that add to 6
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
perm6([1],5). | |
perm6([2],4). | |
perm6([1|T], Current) :- Current < 6 , Next is Current +1, perm6(T, Next). | |
perm6([2|T], Current) :- Current < 6 , Next is Current +2, perm6(T, Next). | |
perm62(_, Current) :- Current >= 6, !. | |
perm62([1],5). | |
perm62([2],4). | |
perm62([1|T], Current) :- Next is Current +1, perm6(T, Next). | |
perm62([2|T], Current) :- Next is Current +2, perm6(T, Next). | |
perm6X(_, Current) :- Current >= 6, !. | |
perm6X([1],5). | |
perm6X([2],4). | |
perm6X([1|T], Current) :- Next is Current +1, perm6(T, Next). | |
perm6X([2|T], Current) :- Next is Current +2, perm6(T, Next). | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment