è¿é¢å¥½è±¡æ¯é¿éçé¢è¯é¢ï¼ç¨Pythonæ¨¡æäºä¸ä¸ã
åæ³å¯è§ï¼/blog.csdn.net/sinat_35562946/article/details/81275080ï¼æ¯è¾è¯¦ç»ã

``````import random
lst = []
for i in range(1,100):
lst.append(i)
lst.append(2015)
def select_n_numbers_from_list(lst,n):
lst2 = lst[:]
lst3 = []
k = 0
for i in range(n):
lst3.append(lst2.pop(random.randint(0,99-k)))
k+=1
return lst3
times_to_run = int(input())
total = 0
for i in range(times_to_run): #Run i times
result = 0
n = random.randint(0,99) #Pick n numbers from list
lst2 = select_n_numbers_from_list(lst, n)
for num in lst2:
result = result^num
total += result
print(total/times_to_run)``````

## SSDåå¥æµè¯èæ¬

ç¬¬äºçï¼ä¹åè®¡åå®åï¼
1ãä»£ç é£æ ¼åç¨æ·çé¢
ä½¿ç¨æ¹æ³ï¼
å°ç¨åºæ¾å¨å¾æµSSDä¸ï¼è¿è¡`main.py`ï¼è¾å¥1,1åè¿è¡åå¥1GBçæµè¯ï¼è¾å¥2æ éå¾ªç¯æµè¯
ç¨åºç®çï¼æµè¯SSDåå¥å¯¿å½
ç¨åºé»è¾ï¼äº§çä¸ä¸ªéæºæä»¶ï¼å¹¶éè¿ä¸æ­å¤å¶ï¼ç´å°å¡«æ»¡SSDãå¨å¡«æ»¡åï¼å¯¹æ¯ä¸ªå¤å¶çæä»¶åæºæä»¶MD5è¿è¡æ¯å¯¹ï¼å¦æåºéåå¤æ­SSDåå¥å¯¿å½å·²å°ï¼åä¹ï¼å é¤æä»¶åä»å¤´å¼å§æµè¯ã
æ¬ç¨åºç¨äºjsonå®ç°äºå¯¹å·²åå¥éçä¿å­ï¼ä½¿ç¨æ¶æ¯è¾æ¹ä¾¿ã

ç®åç¨åºåå«ï¼
1ãdefinations.py

``LOGFILE = 'detDATA.json'``

2ãmain.py

``````import readjson
import savejson
import rndwrite
import os
user_select = int(input())

if user_select == 1: #For test purpose ,short run.
user_select = int(input())
execution_result = rndwrite.writedata(user_select)
logdict.update({'data_written': logdict.get('data_written', 0)+execution_result[0]})
print("{0} megabytes written".format(round(logdict.get('data_written', 0), 3)))
rndwrite.validatedata(os.path.join(os.path.curdir, 'testfile'),execution_result[1])
rndwrite.earsedata(os.path.join(os.path.curdir, 'testfile'))
savejson.save(logdict)
exit(0)
else:
while(True):
execution_result = rndwrite.writedata(32)
logdict.update({'data_written': logdict.get('data_written', 0) + execution_result[0]})
print("{0} megabytes written".format(round(logdict.get('data_written', 0),3)))
rndwrite.validatedata(os.path.join(os.path.curdir, 'testfile'), execution_result[1])
rndwrite.earsedata(os.path.join(os.path.curdir,'testfile'))
savejson.save(logdict)``````

``````import os
import json
from definations import *
if not os.path.exists('detDATA.json'):
testdata = open(LOGFILE, 'w')
logdict = dict()
else:
testdata = open(LOGFILE, 'r')
testdata.close()
return logdict``````

4ãrndwrite.py

``````import numpy as np
import os
import hashlib
import shutil
# V2 : Return file MD5&file size.Improved precision.
# V1 : Return file size.
def writedata(totalgigs):
os.mkdir('testfile')
loop_to_run = int(totalgigs*1024/23.8)-1 # PARAMETER : 23.8
os.chdir('testfile')
np.savetxt('test1'+'.txt', np.random.rand(1000, 1000))
md5file = open('test1.txt','rb')
md5file.close()
print("Created file 'test1.txt' with MD5sum = "+md5)
for i in range(2,loop_to_run):
shutil.copy('test1.txt','test'+str(i)+'.txt')
print("Copied test1.txt -> "+'test'+str(i)+'.txt')
os.chdir('..')
return (int(totalgigs*1024/23.8)*23.8,md5)
def earsedata(mountpoint):
for file in os.listdir(mountpoint):
os.remove(os.path.join(mountpoint,file))
os.rmdir(mountpoint)

def validatedata(mountpoint,checksum):
for file in os.listdir(mountpoint):
print("Checking file "+file+": ")
md5file = open(os.path.join(mountpoint,file),'rb')
md5file.close()
if md5 == checksum:
print("'"+md5+"'"+" matches original file md5 : "+"'"+checksum+"'!") #Too noisy.
pass
else:
print("Found mismatch.Quitting.")
print("At file "+file)
print("Target MD5 = "+md5)
exit(-1)``````

5ãsavejson.py

``````import json
from definations import *

def save(logdict):
testdata = open(LOGFILE,'w')
json.dump(logdict, testdata)``````

## dockerå¸¸ç¨åæ°ç¬è®°

``docker run --name mysqlA12 -e MYSQL_ROOT_PASSWORD=A12A12A12 -d -p 3307:3306 mysql``

--name åè·å®¹å¨å«åï¼å¦ä¸æå®ï¼ç³»ç»å°èªå¨çæä¸ä¸ªID
-e ... ä¸ºæå®ç¹å®æ¨¡æ¿åæ°ä½¿ç¨
-d åå°è¿è¡
-p ç«¯å£æ å° 3307:3306ä¸ºå®¹å¨ç3306æ å°å°æ¬æºç3307ç«¯å£

## 709-543-3382

æ°´é¢ï¼ç¨æ åã

``````x = input()
s = ""
if x[0] == '-':
n = x[1:]
s = x[0]
else:
n = x
b = []

for i in n:
b.append(i)

a = ""
for i in n:
a += b.pop()
print(int(s+a))``````

## ç®åDFSç¤ºä¾

``````/*
* GRAPH :
* 3-2-0-1
* DFS starting from point 3
*/
#include <stdio.h>
#define N 5
void dfs(int u);
int vis[N+1] = {0,};
int mat[5][5]={
0,1,1,0,0,
1,0,0,0,0,
1,0,0,1,0,
0,0,1,0,0,
0,0,0,0,0
}; /1-2-3-4

int main() {
printf("3");
dfs(3);
return 0;
}
void dfs(int u)
{
vis[u]=1;
for(int i=0;i<N;++i)
{
if (!vis[i] && mat[i][u])
{
printf("%d",i);
dfs(i);
}
}
}``````