Hanoi in Prolog
来源:互联网 发布:复制淘宝口令没反应 编辑:程序博客网 时间:2024/06/04 22:51
Resume
Hanoi is a very popular game in acient years. Here’s an implentation of Hanoi with prolog.
Code
hanoi(N) :- move(N,left,center,right).move(0,_,_,_) :- !.move(N,A,B,C) :- M is N-1, move(M,A,C,B), inform(A,B), move(M,C,B,A).inform(X,Y) :- write('Move from '), write(X), write(' to '), write(Y), write('.'), nl.
Result
?- hanoi(3).Move from left to center.Move from left to right.Move from center to right.Move from left to center.Move from right to left.Move from right to center.Move from left to center.true.
0 0
- Hanoi in Prolog
- facts in prolog
- simple query in prolog
- rules in prolog
- recursion in prolog
- prolog
- Prolog
- prolog
- Prolog
- Content is not allowed in prolog
- Content is not allowed in prolog.解决方法
- using swi-prolog jpl in eclipse vista64
- DOM4j:Content is not allowed in prolog
- Content is not allowed in prolog.
- Content is not allowed in prolog.解决
- Content is not allowed in prolog
- SAXParseException: Content is not allowed in prolog
- Content is not allowed in prolog.错误
- [Leetcode]155. Min Stack
- VR虚拟现实&AR增强现实编程(1):VR和AR简介
- java线程(一):线程创建与线程状态
- 数据库编程细节问题 -- 5.group by 的使用
- linux内核栈与用户栈及调用栈观察方法
- Hanoi in Prolog
- C++标准库类型——string
- JAVA并发集合学习总结
- SpringMVC请求后台地址URL没有.*的几种实现方式
- Qt---QTcpSocket连接http服务器
- 图的遍历
- 加速android studio速度
- 重构系列:概论
- Android NDK编译环境配置