Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'defined.': 0.09; 'example:': 0.10; 'output': 0.13; 'lukas': 0.16; 'rotation': 0.16; 'wrote:': 0.16; 'input': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'along.': 0.22; 'seems': 0.23; 'sat,': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; "i've": 0.25; "doesn't": 0.26; 'subject:list': 0.26; 'van': 0.26; 'point.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'looks': 0.29; 'you?': 0.30; 'regardless': 0.31; 'lists': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'suggestion': 0.37; 'starting': 0.37; 'term': 0.60; 'provide': 0.61; 'saturday,': 0.63; 'different': 0.63; 'august': 0.75; 'to:none': 0.91; 'joel': 0.91; 'lot,': 0.95 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:cc :content-type; bh=B5Ua3L7VX0vF3iTznB2rClLVA/WQcKrew1riCzwXn20=; b=oF3kEEoqjeaY+JgMuWqqYenb6ge5dqKUI6M+kcNjbonj2sb+A3p9MLNrQJ9+pe1E9B RtThZL9y8YgCGP4kkrBGzfw5SqF2lOWYOuBPjTWYU99Qldxt17R6d/WznSZk7kvY38Xa 4sbif7FM8lXWfsDa+qmZv4k593dSIR5XqbhDb0u71rtGwTKo9FmyNK9IOr6aKrMM1zEW 6UmBnNQOodVE6l92Wqn07WLC0YQFSsXQ6pBjcuaCaBdaTjY1NHMbDtyUQgdyCjPTQTNu 8YTgDuo8x9pvmo921nNZznEdLVWvUZfrPsUO+mIryPltmMuSEjyjZQDVYtA6e5De+hEJ DXRw== MIME-Version: 1.0 X-Received: by 10.107.18.224 with SMTP id 93mr13876559ios.51.1438469894220; Sat, 01 Aug 2015 15:58:14 -0700 (PDT) In-Reply-To: <9c5dc0c8-0066-4140-9883-f3af14f7b328@googlegroups.com> References: <9c5dc0c8-0066-4140-9883-f3af14f7b328@googlegroups.com> Date: Sat, 1 Aug 2015 18:58:14 -0400 Subject: Re: Most pythonic way of rotating a circular list to a canonical point From: Joel Goldstick Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 1438469901 news.xs4all.nl 2863 [2001:888:2000:d::a6]:40491 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:94874 On Sat, Aug 1, 2015 at 6:51 PM, Lukas Barth wrote: > On Saturday, August 1, 2015 at 11:37:48 PM UTC+2, Emile van Sebille wrote: >> Well, it looks to me that I don't know what a 'canonical rotation' is -- > > That's because it is not defined. ;) > > I need a way to rotate one of these lists in a way so that it will produce the same output every time, regardless of what the input rotation was. > > Example: > > [0,1,2,3,4] => [0,1,2,3,4] > [2,3,4,0,1] => [0,1,2,3,4] > [3,4,0,1,2] => [0,1,2,3,4] > ... > > It doesn't have to be "[0,1,2,3,4]", it can just as well be [2,3,4,1,0], as long as it's always the same. > > Did that make it clearer? > > Thanks a lot, > > Lukas I've been following along. The early suggestion to double one list and see if the second list is in the double list seems to prove they are the same -- one is just rotated to a different starting point. I don't understand the term 'canonical' in this example, but what is it that the solution given doesn't provide for you? -- Joel Goldstick http://joelgoldstick.com