Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.122 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.76; '*S*': 0.00; 'sentence': 0.09; 'cc:addr :python-list': 0.11; 'already,': 0.16; 'cc:name:python list': 0.16; 'for,': 0.16; 'generators.': 0.16; 'remainder': 0.16; 'subject:combinations': 0.16; 'subject:generator': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'all,': 0.19; 'cc:addr:python.org': 0.22; 'filtering': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'away.': 0.31; 'lot.': 0.31; 'probably': 0.32; 'says': 0.33; 'received:google.com': 0.35; 'subject:?': 0.36; 'should': 0.36; 'nov': 0.38; 'pm,': 0.38; 'rather': 0.38; 'short': 0.38; 'even': 0.60; 'john': 0.61; "you'll": 0.62; 'story': 0.63; 'interest': 0.64; 'more': 0.64; 'fire': 0.65; '20,': 0.68; 'subject': 0.69; 'results': 0.69; 'containing': 0.69; 'recursive.': 0.84; 'story:': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=S4GGe+LZJI/p6KuW8IcZ7gHvyoJOG04Im1MtEKsh6UM=; b=QPJxgUVFqNICA9YDQPFKd6O7jkQNkqmaaGs9akG4CF5e9nnmpCfnzVdBlD2Iw85L7B UcOpj10NwbGQT3YBGmVFTPRunms865ITCS3bd4o5ZT/NleADbXBnE7kjH4h4rcDi7KFI y/YG1A/vafQp00m6frebVDrSvIIjjpgq9xNb12PwtPsGwDV2Nb7PYIqDMO6iFlFdnX3M E+8+ZTxZNA+D+F0jvA5Vhh/6xFUZFyEUzbKTZt491yvyIXvl2vt/waqKoVFGxsph45Nt kqQM52Eq/j7GaDr2qDW+QdiHtO4ykK9HrsvOI1z/gKsnOx2Xmu/A0V0jwEETnVkQewfE +vfA== MIME-Version: 1.0 X-Received: by 10.180.24.6 with SMTP id q6mr31974424wif.0.1385067566370; Thu, 21 Nov 2013 12:59:26 -0800 (PST) In-Reply-To: <20131121174614.53450d51@mini.home> References: <20131121174614.53450d51@mini.home> Date: Thu, 21 Nov 2013 12:59:26 -0800 Subject: Re: Recursive generator for combinations of a multiset? From: Dan Stromberg To: "John O'Hagan" Content-Type: multipart/alternative; boundary=f46d043be1fa48955c04ebb62c55 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385067574 news.xs4all.nl 15867 [2001:888:2000:d::a6]:47866 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60174 --f46d043be1fa48955c04ebb62c55 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan wrote: > > Short story: the subject says it all, so if you have an answer already, > fire away. Below is the long story of what I'm using it for, and why I > think it needs to be recursive. It may even be of more general > interest in terms of filtering the results of generators. > I think you probably need permutations rather than combinations. Also, I think you'll need to form a word (partitioned off by spaces), and then check it against a set containing /usr/share/dict/words before recursing for the remainder of the sentence - this should speed things up a LOT. --f46d043be1fa48955c04ebb62c55 Content-Type: text/html; charset=ISO-8859-1

On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan <research@johnohagan.com> wrote:

Short story: the subject says it all, so if you have an answer already,
fire away. Below is the long story of what I'm using it for, and why I
think it needs to be recursive. It may even be of more general
interest in terms of filtering the results of generators.

I think you probably need permutations rather than combinations.

Also, I think you'll need to form a word (partitioned off by spaces), and then check it against a set containing /usr/share/dict/words before recursing for the remainder of the sentence - this should speed things up a LOT.

--f46d043be1fa48955c04ebb62c55--