I’m afraid these are 32-bit installations.

I’m not surprised it doesn’t work on 64-bit installations, but a meaningful error message would have been nice.

You’ll need to rebuild them as 64-bit. I have no experience with that.

My supplier finally moved over to use REST, at about the same time my project that was mothballed, so I don’t have any use for PyXML any more.

]]>What now? Just slam the zip content into phyton27, even the topmost subfolder in the zip was python26. Is this working?

]]>I’m doing some researches about the Kakuro solver.

I wanted an algorithm that can be implemented “fast” (like I have only 24 hours to solve it with a group of 4 members).

I see that your approach is not complicated, yet the graphic is hard.

is it possible to implement it within 24 hours?

thanks ]]>

I was browsing the internet and saw your article on an alphametic solver. Just thought you may be interested in the following Haskell solution. It’s not as concise as Mark’s but it is more generic. All but the comb routine are my own piece of work, but I’m relatively new to Haskell so watch out! Recently as well as this I’ve done a countdown (given list of numbers and total make a calculation using + – / *) and suko ‘brute force’ Haskell programs.

Mike

PS. Have previewed the code it seems you may need to insert spaces in some lines, especially around te where clauses.

-- alphametic.hs

-- Brute force alphametic solver

--

import Data.List (nub, permutations)

import Data.Maybe (fromJust)

```
```-- LookupList is a simple dictionary/map between a letter (key) and the digit it represents

type LookupList = [(Char,Int)]

-- Return combinations of given list

-- E.g. comb 2 [1,2,3] == [[1,2],[1,3],[2,3]]

-- from http://rosettacode.org/wiki/Combinations#Dynamic_Programming_2

comb :: Int -> [a] -> [[a]]

comb m xs = combsBySize xs !! m

where

combsBySize = foldr f ([[]] : repeat [])

f x next = zipWith (++) (map (map (x:)) ([]:next)) next

--createLookup "abcd" [4,5,6,7] => [('a',4), ('b',5), ('c',6),('d',7)]

-- i.e. creates a map of letters(keys) and their associated values (digit)

createLookup :: String -> [Int] -> LookupList

createLookup = zip

-- Given a code (list of keys) and a lookupList returns the calculated value of the code

-- E.g. codeToInt "cda" [(a,1),(b,2),(c,3),(d,5)] => 351

codeToInt :: String -> LookupList -> Int

codeToInt code lookupList = foldl (\b a -> b*10 + a) 0 $ map charToInt code

where charToInt char = fromJust $ lookup char lookupList

-- Creates a list of lookupList for given string which contains unique letters (keys)

-- E.g. createlookupLists "abc" => [ [('a',0),('b',1),('c',2)], [('a',0),('b',1),('c',3)], ...]

-- Note that no attempt is made to disallow 0 values for any letter

createLookupLists letters = map (createLookup letters) combinations

where combinations = concatMap permutations $ comb (length letters) [0..9]

-- Returns true if given lookup is valid

-- A lookup is valid if none of the given keys are zero

lookupIsValid :: String -> LookupList -> Bool

lookupIsValid keys lookupList = all isValid keys

where isValid key = lookup key lookupList /= Just 0

-- Find all solutions to alphametic equation. E.g. for example,

-- "send" + "more" == "money"

-- would be written as

-- alphametic ["send", "more"] "money"

-- which will return

-- [[('m',1),('o',0),('n',6),('e',5),('y',2),('s',9),('d',7),('r',8)]]

alphametic :: [String] -> String -> [LookupList]

alphametic codes sumCode = let

keys = nub.concat $ sumCode : codes -- "sendmory"

keysThatCannotBeZero = nub $ map head (sumCode : codes) -- "sm"

sumOfCodes codes lookup = foldr (\code total -> total + codeToInt code lookup) 0 codes -- returns sum (of list of codes) using given lookup

in

-- return list of (valid) lookups where sum of codes == sum of sumCode

[lookup | lookup <- createLookupLists keys, -- create lookup

lookupIsValid keysThatCannotBeZero lookup, -- where lookup values for "s" and "m" are not zero, and...

sumOfCodes codes lookup == sumOfCodes [sumCode] lookup ] -- ...sum of codes == sum of target

solution1 = alphametic ["bad", "mad" ] "mama"

solution2 = alphametic ["i", "bb" ] "ill"

solution3 = alphametic ["send", "more"] "money"

answer = head solution3

send = codeToInt "send" answer

more = codeToInt "more" answer

money = codeToInt "money" answer

`main :: IO()`

main = do

print "Calculating"

print $ " send : " ++ (show send)

print $ " more : " ++ (show more)

print $ " ---- : -----"

print $ "total : " ++ (show (send + more))

print $ " ---- : -----"

print $ "money : " ++ (show money)

`pep8`

, the compliance checker, enforces it.
]]>