Warning: is_readable() [function.is-readable]: open_basedir restriction in effect. File(D:\InetPub\vhosts\iasync-5360.package\karthiknadig.com\wwwroot/wp-content/plugins/http://karthiknadig.com/wp-content/plugins/lightbox-plus/languages/lightboxplus-en_US.mo) is not within the allowed path(s): (D:/InetPub/vhosts/iasync-5360.package\;C:\Windows\Temp\) in D:\InetPub\vhosts\iasync-5360.package\karthiknadig.com\wwwroot\wp-includes\l10n.php on line 556
Sudoku in Prolog | Normal

Sudoku in Prolog

Karthik Nadig

This is a simple Sudoku solver in Prolog. I was experimenting with Prolog and its backtracking mechanism. In the code, there is a ‘start’ predicate which can be called to run the code and test it out. It is fairly easy to modify and adapt to other problems of this kind. This was written and tested on SWI-Prolog (download here). Source for the Sudoku Solver: sudoku


One Response to “Sudoku in Prolog”

  • 使用 Prolog 求解數獨 | KuoE0's Dots Says:

    […] 由於不希望學生們都到網路上抄襲程式碼,因此定下了兩個額外的規定,第一是不準額外引入任何 library,不過如果是 SWI-Prolog 開啓就會自動引入的則例外。主要是我上網查了一下,發現有許多版本都有引入 CLPFD 這個 library,可以讓解數讀的程式變得非常簡潔,有興趣可以參考以下鏈結:link1、link2。可以發現有趣的是,SWI-Prolog 的官方手冊竟然就有 sudoku solver 作為範例,可見我這個作業實在出的不好,根本意圖使學生上網抄襲。第二的規定是,不用實作數獨的區塊限制,本來是想說題目做些修改應該可以更有效地防止上網抄襲這件事,不過當我宣布後我就後悔了,畢竟抄襲了一份有做區塊限制的程式碼也是符合作業要求。在批改作業時,發現有些許同學都是參考這份程式碼 (link),這份程式碼大量的變數因此令我印象深刻,不過我個人認為這份並不是個好做法就是。 […]

Leave a Reply