Last active
August 29, 2015 14:05
-
-
Save andot/d6d6ee3694c3339fe6d2 to your computer and use it in GitHub Desktop.
计算123456789,所有3位数加法的组合。
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
all_number(Result) :- | |
Digit = [1, 2, 3, 4, 5, 6, 7, 8, 9], | |
member(A1, Digit), | |
member(A2, Digit), | |
member(A3, Digit), | |
member(B1, Digit), | |
member(B2, Digit), | |
member(B3, Digit), | |
member(C1, Digit), | |
member(C2, Digit), | |
member(C3, Digit), | |
fd_all_different([A1, A2, A3, B1, B2, B3, C1, C2, C3]), | |
Result = [A, B, C], | |
A is (A1 * 100 + A2 * 10 + A3), | |
B is (B1 * 100 + B2 * 10 + B3), | |
C is (C1 * 100 + C2 * 10 + C3), | |
A < B, | |
A + B =:= C. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment