Python color ball number maximum even open statistics

Source: Internet
Author: User

Q1: Color ball red ball 33 inside any selected 1 a total of 33, to see which number recently even open the longest statistics out

Color ball record of the previous period Ssq.txt

=====================

2017093 7 7 9 15 22 27 12
2017092 7 7 19 29 32 33 9
2017091 5 5 10 23 28 29 3
2017090 1 7 10 16 22 33 9
2017089 11 12 13 16 23 25 12
2017088 5 5 18 22 23 29 6
2017087 7 7 13 14 19 28 6

=====================

2017093 representative period, followed by the number

-------------------------------------------------

1, first read each record in each row and determine if there are duplicate numbers, if any, the corresponding date, duplicate data in the DIC dictionary

DiC ={}#used to store two colors for each period of duplicate numberWith Open ('C:\\ssq.txt') as File:data=File.readlines ()#Print ("*" *30)     forNodesinchData:node=Nodes.split ()Print("node = ="+Str (node)) forIinchnode:ifNode.count (i) >1: LST=[]                ifI not inchlst:lst.append (i) dic[node[0]=LSTElse:                    Pass            Else:                PassPrint("DIC ======="+str (DIC))

2. Then take out dic all value values, store in a list, and then iterate through the list to find the number with the same number

LST =[]# for storing duplicate numbers for   key in    dic:    if dic[key]!= []:        lst.append (Dic[key])    Else:        passprint( " %%%lst%%== "+str (LST))

3, according to the previous period of the same number of data to find the corresponding key stored in the new list

 forIinchRange (0,len (LST)-1):         forJinchRange (i+1, Len (LST)): CC=list ((Set (Lst[i]). Union (set (LST[J))) ^ (set (Lst[i]) ^set (Lst[j])))#determine if the previous number has the same number        ifLen (cc) >0:list11= []            Print("cc&&&&&&&&"+str (cc))#flg=true            #While FLG:            #find out the dates for repeating numbers             forKvinchDic.items ():#print ("kkk==" +str (k))                #print ("vvv==" +str (v))                Print("KKKKKKKKKKKKKKKKK")                 Print(Type (k))ifv = =cc:Print("&&KK&&"+str (k) +" "+Str (v)) List11.append (k)Print("list11==="+str (list11))

4, in the new list sorting, adjacent elements to find the difference, and take out the smallest difference, the Vlaue and the minimum difference in the storage list

Dic_mix =[] List11.sort ()#Sort By Date            Print("list11=xxxxx=="+str (list11)) Lkks=[]#for storing list11.sort date difference             forIinchRange (0,len (list11)-1):                 forJinchRange (i+1,i+2): DD= ABS (int (list11[i])-Int (list11[j]))ifDd not inchLkks:#if the minimum number of differences is not in the list, addLkks.append (dd) KK=min (LKKS)#Find out the latest date differenceDic_mix.append ((CC,KK))Else:            PassPrint ("Dic_mix = =" +str (dic_mix))

Output

DiC ======={'2017093': ['7'],'2017089': [' A'],'2017091': ['5'],'2017087': ['7'],'2017088': ['5'],'2017092': ['7']}lst=======[['7'], [' A'], ['5'], ['7'], ['5'], ['7']]dic_mix==[(['7'], 1), (['5'], 3), (['7'], 1), (['7'], 1)]

Python color ball number maximum even open statistics

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.