<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Home</title><link>https://sourceforge.net/p/puzzlenumber9/wiki/Home/</link><description>Recent changes to Home</description><atom:link href="https://sourceforge.net/p/puzzlenumber9/wiki/Home/feed" rel="self"/><language>en</language><lastBuildDate>Mon, 01 Jun 2015 01:20:20 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/puzzlenumber9/wiki/Home/feed" rel="self" type="application/rss+xml"/><item><title>Home modified by alhambra1</title><link>https://sourceforge.net/p/puzzlenumber9/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -1,10 +1,12 @@
 **Usage:**

-SOLVE TARGET DENSITY BOARD
+Open a command prompt in the directory the file, "solve.exe" is in. (Windows Vista/7: hold down the Shift key and right-click a folder. The context menu will contain an entry, "Open command window here.")

-TARGET is the highest number to attain
+Type, "solve"

-DENSITY is how many moves to choose from at each choice point; higher DENSITY means a more thorough but also exponentially slower search
+Enter TARGET, the highest number to attain
+
+Enter DENSITY, how many moves to choose from at each choice point; higher DENSITY means a more thorough but also exponentially slower search (between 3 and 6 is recommended)

 BOARD is indexed
 1 2 3
@@ -12,7 +14,8 @@
 7 8 9
 so enter the number from each index in order

-For example, "solve 9 6 5 1 4 8 2 9 6 7 3" searches for a way to get a 9,
+For example, "solve", "9", "6", "5 1 4 8 2 9 6 7 3" 
+searches for a way to get a 9,
 using 6 moves for each choice point,
 on the board
 5 1 4
@@ -27,16 +30,57 @@
 :::haskell

 {-# OPTIONS_GHC -O2 #-}
-import Data.List (sort,sortBy,nubBy)
+import Data.List (sortBy,nubBy)
 import Data.Ord (compare)
-import System.Environment (getArgs)
+import System.Time

-main = do
-    args &amp;lt;- getArgs
-    let board = map (\x -&amp;gt; read x :: Int) (drop 1 $ tail args)
-        target = read (head args) :: Int
-        toTake = read (head (tail args)) :: Int
-    print (map reverse $ reverse $ head $ take 1 $ f target board [] toTake)
+main = do  
+    putStrLn "Puzzle Number 9 Solver Copyright May 2015 alhambra1"
+    putStrLn "\nEnter 'e' at any time to exit"
+    putStrLn "\nEnter target number"
+    target &amp;lt;- getLine  
+    if null target  
+        then main
+        else if head target == 'e'    
+                then return ()        
+                else do 
+                      putStrLn "Enter number of moves at each choice point (density, 3 to 6 recommended)"  
+                      density &amp;lt;- getLine  
+                      if null density  
+                          then main
+                          else if head density == 'e'    
+                                  then return ()        
+                                  else do 
+                                        putStrLn "Enter board numbers separated by spaces"  
+                                        board &amp;lt;- getLine  
+                                        if null board  
+                                            then main
+                                            else if head board == 'e'    
+                                                    then return ()        
+                                                    else do 
+                                                        putStrLn ""
+                                                        time1 &amp;lt;- getClockTime 
+                                                        let b = map (\x -&amp;gt; read x :: Int) (take 9 $ words board)
+                                                            t = read (head (words target)) :: Int
+                                                            d = read (head (words density)) :: Int
+                                                        print (map reverse $ reverse $ head $ take 1 $ f t b [] d)
+                                                        time2 &amp;lt;- getClockTime
+                                                        putStrLn ""
+                                                        print (timeDiffToString $ diffClockTimes time2 time1)
+                                                        putStrLn ""
+                                                        exit
+ 
+exit = do
+     putStrLn "Enter 'a' to start again or 'e' to exit"
+     line &amp;lt;- getLine
+     if null line 
+        then exit
+             else if head line == 'a'
+                     then do putStrLn ""
+                             main
+                          else if head line == 'e'
+                                  then return ()
+                                  else exit

 f target board paths toTake
   | not (null hasTarget) = [(((\(x,y,z)-&amp;gt; z) . head $ hasTarget):paths)]
@@ -45,11 +89,11 @@
                               f target bd (idxs:paths) toTake
  where hasTarget = filter ((==target) . (\(x,y,z)-&amp;gt; x)) ms
        ms = moves board
-       ms' = nubBy (\(x,y,(z:zs)) (x',y',(z':zs')) -&amp;gt; let a = init zs
-                                                          b = init zs'
-                                                      in if not (null a) &amp;amp;&amp;amp; not (null b)
-                                                            then (z == z') &amp;amp;&amp;amp; (last zs == last zs') &amp;amp;&amp;amp; (sort a == sort b)
-                                                            else False) ms
+       ms' = nubBy (\(x,y,z) (x',y',z') -&amp;gt; let a = drop 1 (init z)
+                                               b = drop 1 (init z')
+                                           in if not (null a) &amp;amp;&amp;amp; not (null b)
+                                                 then a == b
+                                                 else False) ms

 moves board = do j &amp;lt;- [1..9]
                  let num = board !! (j - 1)
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">alhambra1</dc:creator><pubDate>Mon, 01 Jun 2015 01:20:20 -0000</pubDate><guid>https://sourceforge.net5fcff4389497d001b750058b86f9d2f91155005e</guid></item><item><title>Home modified by alhambra1</title><link>https://sourceforge.net/p/puzzlenumber9/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -27,7 +27,7 @@
 :::haskell

 {-# OPTIONS_GHC -O2 #-}
-import Data.List (sortBy,nubBy)
+import Data.List (sort,sortBy,nubBy)
 import Data.Ord (compare)
 import System.Environment (getArgs)

@@ -45,11 +45,11 @@
                               f target bd (idxs:paths) toTake
  where hasTarget = filter ((==target) . (\(x,y,z)-&amp;gt; x)) ms
        ms = moves board
-       ms' = nubBy (\(x,y,z) (x',y',z') -&amp;gt; let a = drop 1 (init z)
-                                               b = drop 1 (init z')
-                                           in if not (null a) &amp;amp;&amp;amp; not (null b)
-                                                 then a == b
-                                                 else False) ms
+       ms' = nubBy (\(x,y,(z:zs)) (x',y',(z':zs')) -&amp;gt; let a = init zs
+                                                          b = init zs'
+                                                      in if not (null a) &amp;amp;&amp;amp; not (null b)
+                                                            then (z == z') &amp;amp;&amp;amp; (last zs == last zs') &amp;amp;&amp;amp; (sort a == sort b)
+                                                            else False) ms

 moves board = do j &amp;lt;- [1..9]
                  let num = board !! (j - 1)
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">alhambra1</dc:creator><pubDate>Fri, 29 May 2015 12:22:31 -0000</pubDate><guid>https://sourceforge.net7f0b31f26e47f4fd261689dea81376c7c9c40933</guid></item><item><title>Home modified by alhambra1</title><link>https://sourceforge.net/p/puzzlenumber9/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -1,4 +1,4 @@
-Usage:
+**Usage:**

 SOLVE TARGET DENSITY BOARD

@@ -19,3 +19,93 @@
 8 2 9
 6 7 3
 and yields the result [[2,4]]
+
+&lt;br /&gt;
+**Haskell code:**
+
+~~~~~~
+:::haskell
+
+{-# OPTIONS_GHC -O2 #-}
+import Data.List (sortBy,nubBy)
+import Data.Ord (compare)
+import System.Environment (getArgs)
+
+main = do
+    args &amp;lt;- getArgs
+    let board = map (\x -&amp;gt; read x :: Int) (drop 1 $ tail args)
+        target = read (head args) :: Int
+        toTake = read (head (tail args)) :: Int
+    print (map reverse $ reverse $ head $ take 1 $ f target board [] toTake)
+
+f target board paths toTake
+  | not (null hasTarget) = [(((\(x,y,z)-&amp;gt; z) . head $ hasTarget):paths)]
+  | null ms              = []
+  | otherwise            = do (s,bd,idxs) &amp;lt;- take toTake (sortBy (\(x,y,z) (x',y',z') -&amp;gt; compare x' x) ms')
+                              f target bd (idxs:paths) toTake
+ where hasTarget = filter ((==target) . (\(x,y,z)-&amp;gt; x)) ms
+       ms = moves board
+       ms' = nubBy (\(x,y,z) (x',y',z') -&amp;gt; let a = drop 1 (init z)
+                                               b = drop 1 (init z')
+                                           in if not (null a) &amp;amp;&amp;amp; not (null b)
+                                                 then a == b
+                                                 else False) ms
+
+moves board = do j &amp;lt;- [1..9]
+                 let num = board !! (j - 1)
+                     board' = (take (j - 1) board) ++ [num + 1] ++ (drop j board)
+                 moves' j board' num [j] 0 num
+ where moves' ix board s idxs prev next
+        | (s == 9 || multiple) &amp;amp;&amp;amp; (length idxs &amp;gt; 1) = [(s,board',idxs)]
+        | s &amp;gt; 9 &amp;amp;&amp;amp; mod s 9 /= 0 = []
+        | otherwise = case ix of
+            1 -&amp;gt; if elem 2 idxs then [] else moves' 2 board' (s + b) (2:idxs) next b
+                 ++ (if elem 4 idxs then [] else moves' 4 board' (s + d) (4:idxs) next d)
+                 ++ (if elem 5 idxs then [] else moves' 5 board' (s + e) (5:idxs) next e)
+            2 -&amp;gt; if elem 1 idxs then [] else moves' 1 board' (s + a) (1:idxs) next a
+                 ++ (if elem 3 idxs then [] else moves' 3 board' (s + c) (3:idxs) next c)
+                 ++ (if elem 4 idxs then [] else moves' 4 board' (s + d) (4:idxs) next d)
+                 ++ (if elem 5 idxs then [] else moves' 5 board' (s + e) (5:idxs) next e)
+                 ++ (if elem 6 idxs then [] else moves' 6 board' (s + f) (6:idxs) next f)
+            3 -&amp;gt; if elem 2 idxs then [] else moves' 2 board' (s + b) (2:idxs) next b
+                 ++ (if elem 5 idxs then [] else moves' 5 board' (s + e) (5:idxs) next e)
+                 ++ (if elem 6 idxs then [] else moves' 6 board' (s + f) (6:idxs) next f)
+            4 -&amp;gt; if elem 1 idxs then [] else moves' 1 board' (s + a) (1:idxs) next a
+                 ++ (if elem 2 idxs then [] else moves' 2 board' (s + b) (2:idxs) next b)
+                 ++ (if elem 5 idxs then [] else moves' 5 board' (s + e) (5:idxs) next e)
+                 ++ (if elem 7 idxs then [] else moves' 7 board' (s + g) (7:idxs) next g)
+                 ++ (if elem 8 idxs then [] else moves' 8 board' (s + h) (8:idxs) next h)
+            5 -&amp;gt; if elem 1 idxs then [] else moves' 1 board' (s + a) (1:idxs) next a
+                 ++ (if elem 2 idxs then [] else moves' 2 board' (s + b) (2:idxs) next b)
+                 ++ (if elem 3 idxs then [] else moves' 3 board' (s + c) (3:idxs) next c)
+                 ++ (if elem 4 idxs then [] else moves' 4 board' (s + d) (4:idxs) next d)
+                 ++ (if elem 6 idxs then [] else moves' 6 board' (s + f) (6:idxs) next f)
+                 ++ (if elem 7 idxs then [] else moves' 7 board' (s + g) (7:idxs) next g)
+                 ++ (if elem 8 idxs then [] else moves' 8 board' (s + h) (8:idxs) next h)
+                 ++ (if elem 9 idxs then [] else moves' 9 board' (s + i) (9:idxs) next i)
+            6 -&amp;gt; if elem 2 idxs then [] else moves' 2 board' (s + b) (2:idxs) next b
+                 ++ (if elem 3 idxs then [] else moves' 3 board' (s + c) (3:idxs) next c)
+                 ++ (if elem 5 idxs then [] else moves' 5 board' (s + e) (5:idxs) next e)
+                 ++ (if elem 8 idxs then [] else moves' 8 board' (s + h) (8:idxs) next h)
+                 ++ (if elem 9 idxs then [] else moves' 9 board' (s + i) (9:idxs) next i)
+            7 -&amp;gt; if elem 4 idxs then [] else moves' 4 board' (s + d) (4:idxs) next d
+                 ++ (if elem 5 idxs then [] else moves' 5 board' (s + e) (5:idxs) next e)
+                 ++ (if elem 8 idxs then [] else moves' 8 board' (s + h) (8:idxs) next h)
+            8 -&amp;gt; if elem 4 idxs then [] else moves' 4 board' (s + d) (4:idxs) next d
+                 ++ (if elem 5 idxs then [] else moves' 5 board' (s + e) (5:idxs) next e)
+                 ++ (if elem 6 idxs then [] else moves' 6 board' (s + f) (6:idxs) next f)
+                 ++ (if elem 7 idxs then [] else moves' 7 board' (s + g) (7:idxs) next g)
+                 ++ (if elem 9 idxs then [] else moves' 9 board' (s + i) (9:idxs) next i)
+            9 -&amp;gt; if elem 5 idxs then [] else moves' 5 board' (s + e) (5:idxs) next e
+                 ++ (if elem 6 idxs then [] else moves' 6 board' (s + f) (6:idxs) next f)
+                 ++ (if elem 8 idxs then [] else moves' 8 board' (s + h) (8:idxs) next h)
+          where multiple = length idxs == 2 &amp;amp;&amp;amp; prev == next &amp;amp;&amp;amp; mod s 9 == 0
+                [a,b,c,d,e,f,g,h,i] = board
+                board' = if s == 9
+                            then (take (headIdxs - 1) board) ++ [9] ++ (drop headIdxs board)
+                            else if multiple
+                                    then board''
+                                    else (take (headIdxs - 1) board) ++ [next + 1] ++ (drop headIdxs board)
+                board'' = map (\(x,y) -&amp;gt; if x == headIdxs then y * 2 else if x == last idxs then 1 else y) (zip [1..] board)
+                headIdxs = head idxs
+~~~~~~
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">alhambra1</dc:creator><pubDate>Fri, 29 May 2015 00:10:21 -0000</pubDate><guid>https://sourceforge.net8b081e2f43973336ce2ee281b6b1960be97867e6</guid></item><item><title>Home modified by alhambra1</title><link>https://sourceforge.net/p/puzzlenumber9/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,8 +1,21 @@
-Welcome to your wiki!
+Usage:

-This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: [SamplePage].
+SOLVE TARGET DENSITY BOARD

-The wiki uses [Markdown](/p/puzzlenumber9/wiki/markdown_syntax/) syntax.
+TARGET is the highest number to attain

-[[members limit=20]]
-[[download_button]]
+DENSITY is how many moves to choose from at each choice point; higher DENSITY means a more thorough but also exponentially slower search
+
+BOARD is indexed
+1 2 3
+4 5 6
+7 8 9
+so enter the number from each index in order
+
+For example, "solve 9 6 5 1 4 8 2 9 6 7 3" searches for a way to get a 9,
+using 6 moves for each choice point,
+on the board
+5 1 4
+8 2 9
+6 7 3
+and yields the result [[2,4]]
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">alhambra1</dc:creator><pubDate>Fri, 29 May 2015 00:07:58 -0000</pubDate><guid>https://sourceforge.netdbb2d4f30bbad3d64a0ae7d29e91309a4e598ce9</guid></item><item><title>Discussion for Home page</title><link>https://sourceforge.net/p/puzzlenumber9/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Usage: &lt;/p&gt;
&lt;p&gt;SOLVE TARGET DENSITY BOARD &lt;/p&gt;
&lt;p&gt;TARGET is the highest number to attain &lt;/p&gt;
&lt;p&gt;DENSITY is how many moves to choose from at each choice point; higher DENSITY means a more thorough but also exponentially slower search &lt;/p&gt;
&lt;p&gt;BOARD is indexed &lt;br /&gt;
1 2 3 &lt;br /&gt;
4 5 6 &lt;br /&gt;
7 8 9 &lt;br /&gt;
so enter the number from each index in order &lt;/p&gt;
&lt;p&gt;For example, "solve 9 6 5 1 4 8 2 9 6 7 3" searches for a way to get a 9, &lt;br /&gt;
using 6 moves for each choice point, &lt;br /&gt;
on the board &lt;br /&gt;
5 1 4 &lt;br /&gt;
8 2 9 &lt;br /&gt;
6 7 3 &lt;br /&gt;
and yields the result [[2,4]]&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">alhambra1</dc:creator><pubDate>Thu, 28 May 2015 19:16:58 -0000</pubDate><guid>https://sourceforge.net768f1d9a8d08ce4e08bbb5a1febc61a0e91d4904</guid></item><item><title>Home modified by alhambra1</title><link>https://sourceforge.net/p/puzzlenumber9/wiki/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Welcome to your wiki!&lt;/p&gt;
&lt;p&gt;This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: &lt;span&gt;[SamplePage]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The wiki uses &lt;a class="" href="/p/puzzlenumber9/wiki/markdown_syntax"&gt;Markdown&lt;/a&gt; syntax.&lt;/p&gt;
&lt;p&gt;&lt;h6&gt;Project Members:&lt;/h6&gt;
&lt;ul class="md-users-list"&gt;
&lt;li&gt;&lt;a href="/u/alhambra1"&gt;alhambra1&lt;/a&gt; (admin)&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;&lt;span class="download-button-556762197929e563c5e5ec96" style="margin-bottom: 1em; display: block;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">alhambra1</dc:creator><pubDate>Thu, 28 May 2015 18:44:41 -0000</pubDate><guid>https://sourceforge.net784e36d40974408a1e7e9af3e1b58523cf98bf4e</guid></item></channel></rss>