Python Exercise 6

Source: Internet
Author: User

#!/usr/bin/python#-*-coding:utf-8-*- fromCollectionsImportdeque fromMathImportlog10defpermute (SEQ, index): Seqc=seq[:] seqn=[Seqc.pop ()] Divider= 2 whileSeqc:index, New_index=divmod (Index,divider) Seqn.insert (New_index, Seqc.pop ()) Divider+ = 1returnseqndefz62 ():#0~7 Eight numbers are placed on eight vertices of the cube, and the sum of the four numbers of each polygon is equalA=[0, 1, 2, 3, 4, 5, 6, 7] n=sum (a)ifN%2==1:        return    Else: N/=2 forIinchRange (0,40320): v1=permute (a,i)if(V1[0] + v1[1] + v1[2] + v1[3] = = N andV1[0]+ v1[1] + v1[4] + v1[5]== n andV1[0]+ v1[2] + v1[4] + v1[6] = = N andV1[0]+ v1[4] + v1[4]+ v1[7] = = N andV1[0]+ v1[1] > N/2 andV1[5] > V1[7]):            Printv1returndefz58 ():#Construction Latin side: the Latin side refers to the n*n phalanx where each row of 1 to N of these numbers, only one occurrenceSs=6D= Deque (Range (1,ss+1))     forIinchRange (ss): D.rotate (1)        PrintList (d)returndefz59 ():" "answers such as 1 2 3 4 5 6 Each column right is greater than the left of each row is greater than the fill in 1~6 6 digits" "T=range (2,6)     forIinchT: forJinchT: forMincht:n=14-i-j-mifI!=j!=m!=i andJ>i andN>m andN>I:Print[1, I,j]Print[m,n,6]    returndefISS (N): s="'. Join (Map (str,n)) T=set (s) M=Len (s)returnLen (t) ==m and '0'  not inchTdefz60 ():" "If 192,384,576 384 is the second number is 192 of twice times 576 number the second is 192 times the number is 1~9" "     forIinchRange (111,333): T=[i,2*i,3*i]ifISS (t):PrintTdefz61 ():#such as 361,529,784, their three number is completely squared, such as 361=19*19 at the same time the number is 1~9Ge=[x*x forXinchRange (11,31)]     forIinchGE: forJinchGE: forMinchGe:t=[I,j,m]ifI<j<m andISS (t):PrintTdefzz68 (n):ifn==2:returnFilterLambdaX:x%2==0,range (11,99)) T=[] P=zz68 (n-1)     forJinchP: forIinchRange (10): nn=j*10+IifISS ([NN]) andnn%n==0:t.append (NN)returnTdefz66 ():" "In addition to restore-x7x ~ xx/--------~/xxxxx ~ x77 ~------~ x7x ~ x7x ~----~ XX ~ XX ~---~ 0" "     forIinchRange (1,10):         forJinchRange (11,100): M2= i *J M3= 7 *Jif((m2% 100 = = 77 andM2 >100) and(M3/10% 10 = = 7 andM3 > 100)):                 forKinchRange (1,10):                    ifk*j<100:                        Print[i*100+70+K,j]returndefz67 ():" "In addition to restore 2 ~ x7xxx ~ xxx/-----------~/xxxxxxxx ~ xxxx ~------~             xxx ~ XXX ~-------~ xxxx ~ XXX ~---------~ XXXX ~ xxxx ~---------~ 0" "g=LambdaX,y:map (LambdaA,b=x:int (log10 (a*b)) +1,y) ==[4,3,3,4] t=[8,9]     forIinchRange (100,142):         forJinchT: forMinchT: forNincht:n1=J * 10000+7000+m * 100+N e=[j,7, M,n]ifG (I,e) and(M * 100+n) *i/10000==10:                        PrintN1,i,n1*Ireturndefz68 ():#The number consists of 123456789, of which the first two are divisible by 2, 123 divisible by 3 ,    #the first n bits can be divisible by N, asking him how much    PrintZz68 (9)defz63 ():" "reduced Restore ~ Pear-ara-----------------~ PEA The different letters represent different numbers." "T=range (0,10)     forIinchT: forJinchT: forKinchT:a,b,c= 100+k * 10+i,1000+k * 100+i * 10+j,i * 100+j * + +Iifa==b-C:Print[A,b,c]defz64 ():" "multiplicative restore where a represents 0~9 the first five digits Z represents 0~9 after five digits ~ AZA * Aaz-----------------~ AAAA ~ Aazz ~ ZAA-----------------~ Zazaa" "g=LambdaY:"'. Join (Map (LambdaX:x>'4'  and '0' or '1', str (y))) T=range (1,5) M=range (5,10) T1=filter (LambdaY:g (y) = ='101', Range (100,500))     forIinchT1: forJinchFilterLambdaY,x=i:g (y*x) = ='011', T): forKinchFilterLambdaY,x=i:g (y*x) = ="1100", T): forMminchFilterLambdaY,x=i:g (y*x) = ="1111", M): JJ=j *100+k *10+mmifG (jj*i) = ='01011':                        PrintI,JJreturndefz65 ():" "Multiply-Restore 2 ~ PPP * PP-----------~ PPPP ~ PPPP-------------~ ppppp 18 of them p The position is full of prime 2,3,5,7" "    defg (n): t=str (n)returnLen (Filter (LambdaX:int (x)inch(2,3,5,7), t)) = =len (t) forIinchRange (222,778):         forJinchRange (11,78):            ifG (i) andG (j) andG (I*J) andG (J%10*i) andG (int (J/10) *i):Printi,j,i*Jif __name__=='__main__': S=""     forIinchRange (58,69): S+='Z'+str (i) +'() \ n'    exec(s)

Python Exercise 6

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.