Deutsch English Français Italiano |
<thar3q$hqs$1@gioia.aioe.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!7moiFboVY/XrrMO40qQaOA.user.46.165.242.91.POSTED!not-for-mail From: AIEO <zzz@aol.com> Newsgroups: fr.comp.lang.python Subject: [NON RESOLU] : Panne en Python... Date: Sun, 2 Oct 2022 03:56:10 +0200 Organization: Aioe.org NNTP Server Message-ID: <thar3q$hqs$1@gioia.aioe.org> References: <th0qot$afg6$1@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gioia.aioe.org; logging-data="18268"; posting-host="7moiFboVY/XrrMO40qQaOA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Content-Language: fr X-Notice: Filtered by postfilter v. 0.9.2 Bytes: 2375 Lines: 42 Le 28/09/2022 à 08:49, Dominique a écrit : Bon, j'abdique. J'ai tenté avec itertools.permutations. Cette fonction est très intéressante, mais elle échoue avec 15 chiffres => freeze de mon PC ! J'ai recopié la solution du livre : **************************** l15=[n for n in range(1,16)] v=[[3,8,15],[7,14],[1,6,13],[5,12],[4,11],[3,10],[2,9],[1,8],[7],[6,15],[5,14],[4,13],[3,12],[2,11],[1,10]] t=[] for a in range(1,16): for b in v[a-1]: for c in v[b-1]: for d in v[c-1]: for e in v[d-1]: for f in v[e-1]: for g in v[f-1]: for h in v[g-1]: for i in v[h-1]: for j in v[i-1]: for k in v[j-1]: for l in v[k-1]: for m in v[l-1]: for n in v[m-1]: for o in v[n-1]: t.append([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o]) #print(t) for l in t: if sorted(l)==l15: print(l) **************************** Elle me donne deux réponses réciproques : [8, 1, 15, 10, 6, 3, 13, 12, 4, 5, 11, 14, 2, 7, 9] [9, 7, 2, 14, 11, 5, 4, 12, 13, 3, 6, 10, 15, 1, 8] Mais je n'arrive pas bien à comprendre cette solution...