How to rearrange array using Python?

Martin Schöön martin.schoon at gmail.com
Mon Aug 17 17:14:20 EDT 2015


Den 2015-07-31 skrev Martin Schöön <martin.schoon at gmail.com>:
> Den 2015-07-31 skrev Thomas 'PointedEars' Lahn <PointedEars at web.de>:
>> Mark Lawrence wrote:
>>> 
>>> I'm not absolutely certain but I think you're into what's known as a
>>> constraint satisfaction problem, in which case this
>>> https://pypi.python.org/pypi/python-constraint/1.2 is as good a starting
>>> point as any.  If I'm wrong we'll soon get told :)
>>
>> It is a CSP indeed, and as I was reading the OP I was thinking of SWI-
>>
> Thanks guys, I will follow up on the CSP lead. It is not something I
> have prior experience of so it will be interesting.
>
Brief progress report (just to tell you that your advice has been
'absorbed').

I have been reading a bit, here is one example.
http://kti.ms.mff.cuni.cz/~bartak/constraints/index.html
Interesting stuff but sometimes head-spinning -- I don't always follow
the lingo.

I have also downloaded and installed Python-Constraint. It works as
advertised as long as I replicate the examples found at:
http://labix.org/python-constraint
I can even scale some of the examples.

Creating my own examples has proven harder -- in part because the
documentation is minimalistic but also because I have not tried very
hard. We have, finally, got some nice summer weather here...

I have tried my hand at a *very* basic room placement problem. It
works
apart from the fact that I have not figured out how to tell the solver
there are limits to how many occupants each room can house.

Yesterday I started on a basic Kenken example. I need to experiment
a little to find a way to add the needed division and subtraction
constraints. I haven't given this much thought yet.

Today I found Numberjack:
http://numberjack.ucc.ie/
It seems better documented than Python-Constraint but that is all
I know. Anyone with experience of Numberjack?

In summary: I am having fun using ipython and org-mode for emacs.
I am not making much headway but then I don't have a dead-line
:-)

/Martin



More information about the Python-list mailing list