This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/pyswip/examples/sendmoremoney/money.py
2010-06-01 00:33:32 +01:00

22 lines
436 B
Python

# -*- coding: utf-8 -*-
# S E N D
# M O R E
# + -------
# M O N E Y
#
# So, what should be the values of S, E, N, D, M, O, R, Y
# if they are all distinct digits.
from pyswip import Prolog
letters = "S E N D M O R Y".split()
prolog = Prolog()
prolog.consult("money.pl")
for result in prolog.query("sendmore(X)"):
r = result["X"]
for i, letter in enumerate(letters):
print letter, "=", r[i]
print "That's all..."