How do I solve something like this using Prolog:

There are 5 numbers, A, B, C ,D and E.
C+E = 14
B+1 = D
A = 2*B-1
B+C = 10
A+B+C+D+E = 30


What are the values of each number?


I have solved similar problems with prolog, so I was wondering if it was possible to solve this one.
C+E=14
B+1=D
A=2B-1
B+C=10
A+B+C+D+E=30


A+(D-1)+C+D+E=30
A+C+2D+E=31
A+2D+(C+E)=31
A+2D+14=31
A+2D=17
(2B-1)+(2[B+1])=17
4B=16
B=4
D=5
C=6
E=8
A=7
PT_, I have solved the problem as well, what I was looking for was a way of having the computer solve it using a Prolog program. I want to learn so I can use it for more complex problems.
You should consider this page: http://cs.union.edu/~striegnk/learn-prolog-now/html/node39.html#sec.l5.arithmetic and the following on as starting points.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement