Newsgroups: comp.lang.python
From: "Juhani Ylikoski" <antti.yliko...@elisanet.fi>
Date: Mon, 12 Nov 2012 23:02:36 +0200
Local: Mon, Nov 12 2012 4:02 pm
Subject: Writing Donald E. Knuth based code in Python, cont'd
Following comes a working, debugged Python program which computes the
permutations of the integers 1, 2, 3 - n after Donald E. Knuth. I present it as an example of writing straightforward, easy Knuth-based code in a language with no GOTO statement. The Python program has been written after the DFA construct I
This program was needed for a real problem, namely computing optimal
http://en.wikipedia.org/wiki/Bughouse_chess
Knuth became criticized in the newsgroup; but to my opinion his books
----------------------------------------------------------------------
class DFA(object):
# Iteratively generate all permutations of n integers 1-n.
def __init__(self, n):
def E1(self): # Phase 1 in Knuth's text
def E2(self): # Phase 2 in Knuth's text
def E3(self): # Phase 3 in Knuth
def E4(self): # Phase 4
def runDFA(self):
----------------------------------------------------------------------
yours sincerely, Antti J Ylikoski
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||