Position: Home page » Ethereum » Lettercoin Python

Lettercoin Python

Publish: 2021-05-13 04:53:39
1. Initial blockchain
features:
blockchain is an immutable and orderly chain record composed of block records. The main features are as follows:
1: decentralization
e to the use of Distributed Accounting and storage, there is no centralized hardware or management organization, the rights and obligations of any node are equal, and the data blocks in the system are jointly maintained by the nodes with maintenance function in the whole system. Thanks to the decentralization of blockchain, bitcoin also has the characteristics of decentralization
2: openness
the system is open, in addition to the private information of the parties to the transaction is encrypted, the data of the blockchain is open to all, and anyone can query the blockchain data and develop related applications through the open interface, so the information of the whole system is highly transparent
3: autonomy
blockchain adopts consensus based specifications and Protocols (such as a set of open and transparent algorithms) to enable all nodes in the whole system to exchange data freely and safely in a de trusted environment, so that the trust in "people" is changed into the trust in machines, and any human intervention does not work
4: information cannot be tampered with
once the information is verified and added to the blockchain, it will be stored permanently. Unless more than 51% of the nodes in the system can be controlled at the same time, the modification of the database on a single node is invalid, so the data stability and reliability of the blockchain are extremely high
5: anonymity
since the exchange between nodes follows a fixed algorithm, their data interaction does not need to be trusted (the program rules in the blockchain will judge whether the activity is effective by themselves), so the counterparties do not need to make the other party trust themselves by disclosing their identities, which is very helpful for credit accumulation
compared with the traditional distributed database, there are two main differences:
1: the traditional distributed database supports adding, deleting, checking and modifying, while the blockchain only supports searching and inserting, and blocks cannot be deleted or modified
2: the traditional distributed database is generally a master-slave structure: master and slaves structure. In order to ensure high availability, it is realized by standby master, while the blockchain is a decentralized database. There is no master-slave structure
blockchain and bitcoin:
when it comes to blockchain, most people talk about bitcoin. However, blockchain is not equal to bitcoin. It is now the era of blockchain 3.0, and bitcoin is only the proct of blockchain 1.0
the evolution mode of blockchain is:
& ᦇ 9642; Blockchain 1.0 digital currency; Blockchain 2.0 digital assets and smart contracts; Blockchain 3.0 - Implementation of distributed applications in various instries
classification of blockchain:
public blockchains
public blockchain means that any indivial or group in the world can send transactions, and transactions can be effectively confirmed by the blockchain, and anyone can participate in its consensus process. Public blockchain is the earliest and the most widely used blockchain. The virtual digital currencies of bitcoin series are all based on public blockchain. There is only one blockchain corresponding to this currency in the world
consortium blockchains
instry blockchains: multiple preselected nodes are designated as bookkeepers within a certain group, and the generation of each block is jointly determined by all preselected nodes (preselected nodes participate in the consensus process). Other access nodes can participate in transactions, but not the bookkeeping process (essentially, trusteeship bookkeeping), It just becomes distributed accounting, the number of preselected nodes, and how to determine the bookkeeper of each block to become the main risk point of the blockchain). Anyone else can conct limited query through the open API of the blockchain
private blockchain: it only uses the general ledger technology of blockchain for bookkeeping. It can be a company or an indivial, enjoying the write permission of the blockchain. This blockchain is not very different from other distributed storage schemes Dec2015) conservative giants (traditional finance) want to experiment with private blockchain, while the application of public chain, such as bitcoin, has been instrialized, and the application procts of private chain are still groping.
2. Xinwei B3, ant S9, yibit, Shenma, how do you want to mine? brother
3. All cryptocurrencies are written in C / C + +, Python is too slow, only for algorithm.
4. def func(money):
return f' RMB: 20 US dollars: {money * 20} & # 39

I don't know what you mean, but it's very simple. I don't know what effect you want. You'd better give an example, such as what to input and what to output
5.

#coding:utf-8

import random

def mntb(T):

a = 0

b = 0

while a < T and b < T:

num = random.randint(0,1)

#print num 这里你可以看到每次抛的硬币的正反面情况

if num == 0:

a += 1

else:

b += 1

if a == T:

print u'b的得分是:%d '%b

return 'a won'

if b == T:

print u'a的得分是:%d '%a

return 'b won'


#你执行这个函数就可以了,T代表你设置的分数 mntb(T),代码写的比较啰嗦 嘿嘿

按照你题目的意思要这样修改一下:看题大意了,并不是从0开始统计

#coding:utf-8

import random

def mntb(T,a,b):#a代表p1目前的分数 b代表p2目前的分数

while a < T and b < T:

num = random.randint(0,1)

#print num 这里你可以看到每次抛的硬币的正反面情况

if num == 0:

a += 1

else:

b += 1

if a == T:

print u'p2的得分是:%d '%b

return 'p1 won'

if b == T:

print u'p1的得分是:%d '%a

return 'p2 won'


#你执行这个函数就可以了,T代表你设置的分数 mntb(T,a,b)

6. I am the questioner, this problem has been solved, so this problem is invalid
7.

Idea: suppose there is an array arr, in which the int value represents the weight of silver coins, and the subscript represents the number of silver coins

loop (non recursive): assign the first value of the array to the variable TMP, loop from the second variable to the last, compare the variable in the loop with the TMP value, if not, return the decimal subscript

recursion: with the idea of dichotomy, silver coins are divided into two piles (if it can't be equally divided, leave the middle one), and take the pile with small weight to continue dichotomy. When there is only one left, it is the desired

. The following writing method returns the subscript. You can also assume that the coin is a data type, and then return that type

< pre t = "code" L = "Python" >/ usr/bin/python
#-*- coding:utf-8- *-

? Returns the minimum subscript
defgetmin (Arr1):
iflen (Arr1) = = 0: Return-1

TMP = Arr1 [0]
index = 0
forcurnarr1:
iftmp= cur:
return0iftmp< curelseindex
index+=1
return-1

real_ Index = 0
# return minimum subscript recursion
defgetminrecursion (Arr1):
global real_ index
n=len(arr1)
ifn==0:return-1

ifn==1:returnreal_ index
ifn==2:returnreal_ indexifarr1[0]< arr1[1]elsereal_ index+1

sum1=sum(arr1[0:int(n/3)])
sum2=sum(arr1[int(n/3):int(n/3)*2])

ifsum1==sum2:
real_ index+=int(n/3)*2
returngetMinRecursion(arr1[int(n/3)*2:n+1])
ifsum1< sum2:
returngetMinRecursion(arr1[0:int(n/3)])
else:
real_ index+=int(n/3)
returngetMinRecursion(arr1[int(n/3):int(n/3)*2])

arr=[1,1,1,1,1,1,0,1,1]
print("% d"% getMin(arr))
print("% d"% getMinRecursion(arr))
8. Now, we're going to have the conrange of 0
=
= < print > Cannot initialise Evolution's mail component.1:", i, " 5:", j, " 10: ", k k
/cnt + /cnt + /cnt +




. The results of the following, the total 121 1211 of total 1211 of total 1211 of total 121 1 1 1 1 1 1: 0 0 5: 0 0 0 0: 0 0 0 0: 0 0 0 0 0 0: 0 0 0 0 0 0 0: 10 10 10 10 10 10 10 10 10: 7
1: 0 5: 8 10: 6
1: 0 5: 10: 5
1: 0 5: 12 10: 4
1: 0 5: 14 10: 3
1: 0 5: 16 10: 2
1: 0 5: 18 10: 1
1: 0 5: 20 10: 0
1: 5 5: 5: 10 10 10: 9 10 10: 9 10 10 10 10 10: 9/br br/br/ >1: 5 5 5 5 5 5 5 5 5 5: 5 5 5 10 10: 5 10 10 10 10: 7 7 7 10 10 10 10 10 7 7 7 10 10 10 10 10 10 6 brbrbr / >1: 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5: 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 5 5 5 5 5 5 5 5 5 5 5 1: 5: 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 5 5 5: 10 5 5 5: 14 14 14 10 10 10 10 10 10: 10 10 5: 16 10 10 10: 16 10 10 10 10: 1 1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 8 81: 15 5 5 5 5 5 5: 15 5 5 5 5: 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 10 10 10 10 10 10 10 10 10 7 7 7 7 7 10 5 5 5 5 10 10 10 10 10 10 brbr / >1: 15 15 5 5 5 5 5 5 5 10 10 10 10 1:15 5: 11 10:3
1:15 5:13 10:2
1:15 5:15 10: 1
1:15 5:17 10: 0
1:20 5:0: 0: 8
1:20 5:0: 8 6
1: 20 5 5 5: 6 10 10 10: 6 10 10 10 10: 5 5 10 10 10: 5 5 10 10: 5 10 10: 20 5: 20 20 5: 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 3
1: 20 5 20 5 5: 12 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 2 2
1: 20 20 20 5 5 20 5 5: 20 20 20 5 5 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 2 brbr
1: 20 20 20 5 20 5 20 5 10 5: 5
1:25 5:7 10:4
1:25 5:9 10:3
1:25 5: 11 10:2
1: 25 5: 13 10: 1
1: 25 5: 15 10:0
1: 30 5:0 10: 7
1: 30 5: 5 5: 2 10 10 10 10 10 10 10 10 10 10 10 10 10 10: 30 30 5 5 5: 30 5 5 5 5: 4 br br br/ > >1: 30 5: 6 10 10: 6 10 10: 4 4
1: 30 5 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 2
1: 30 5 5 5 5: 30 5 5 5 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 2
1: 30 5 5 5 5 5 5: 30 5 5 5 5 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1:35 5: 5 10:4
1:35 5:7 10:3
1:35 5:9 10: 2
1:35 5:11 10: 1
1:35 5:13: 0
1:40 5:0: 6
1:40 5: 2 10: 5
/ / /> /........./>1: 40 40 5 5: 4 4 10 10 10 10 10: 4 4 4
>1: 40 5 5: 40 5 10 10: 2 21: 40 5 5 10 10 10 10 10 10 10 10: 1 40 5 10 10 10 10 10 10 10 10 10 10 10 10 10 10: 1 40 5 10 10 10 10 10 10 10 10 10 10 10 10 10: 01: 45 5 5 5 5 5: 10 10 10 10 10 10 10 10 10: 01: 45 5 5 5 5 5 5 5 5 5 10 10: 10 10 10 10: 10 10 10 10 10 10 10: 5 5 5 10 10 10 10: 5 5 5: 5 5 5 5 5
1:45 5: 9 10: 1
1:45 5: 11 10: 0
1:50 5: 0 10: 5
1: 50 5: 2 10: 4
1: 50 5: 4 10: 3
1: 50 5: 4 10: 3
1: 50 5: 6 10: 2
1: 50 5: 8: 1
1: 50 5 5: 10 10 10 10 10 10: 10 10 10 10 10: 10 10 10 10 10 10: 10 10 10: 555 5: 1 10 10: 411: 555 5: 4
1: 555 5: 3 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 2 2
1: 555 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 10 10 10 10 10 10 10 10 10 10 2
1: 555 5 5 5 5 5 5 5: 7 1: 60 5: 4 10: 2
1:60 5: 6 10: 1
1:60 5:8 10: 0
1:65 5: 1 10: 3
1:65 5:3 10: 2
1:65 5:5 10: 1
1:65 5:5 10: 1
1:65 5: 7 10: 0
1: 70 5:0 10: 10: 3
1: 70 5 5: 70 5 5: 2 10 10 10 10: 2 10 10 10: 2 2 10 10: 2 2 10 10 10: 2 2 10 10: 2
1: 70 5 10: 1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10: 10 10 10 10 10: 2 21: 75 5 5 5 5: 1 10 10 10 10: 10 10 10 10 10: 2 2
1: 75 5 5 5 5 5 5 10 10: 3 3 3 3 3 3 10 10 10 10 10: 3 3 3 3 3 3 3 10 10 10 10 10 10: 3 3 3 3 3 3 3 3 3 10 10 10 10 10 10 10 10: 3 3 3 3 3 3 3 3 3 3 80 5: 0
1: 85 5:1 10: 1
1: 85 5:3 10: 0
1: 90 5:0 10: 1
1: 90 5: 2: 0
1: 90 5: 2 10: 0
1: 95 5: 1 10: 0
1: 100 5: 0: 0
121
9. < pre t = "code" L = "Python" > choices = [1,5,16,23,33]
cache = {}
deff (x):
ifxincache: # note 2
return cache [x]

IFX & gt; 5: Note 1
ch = [5,16,23,33]
elifx & gt; 80:
#ch=[16,23,33]
else:
ch=choices
l=[x-cforcinchifx>= c]
Ifall (L): # all are true, that is, there is change
cache [x] = min ([f (x1) forx1inl]) + 1
else:
cache [x] = 1
return cache [x] < / pre >


the idea of the algorithm comes from another building where you ask the same question, and there is a circular algorithm. To be honest, I can't understand it... It's better to understand recursion

The first version of


does not have two annotations; The efficiency is so bad that 99 can't be counted


note 1

I began to think that it should be that there are too many useless calculations when recursion occurs. After thinking for a long time, I didn't need to consider the small denomination when the amount is large, so I added judgment; But what is the basis of exclusion? If it's more than 5 yuan, don't consider 1 yuan. Obviously, what about the following? It seems that we should take the least common multiple, but we can't prove it...

however, even so, we can only improve the efficiency of numbers less than 200, and the efficiency is still very poor


note 2

later, I thought that in this process, we calculated F (x) for different x, and there are many repetitions, and the results for the same X, f (x) should be the same, So a cache is added to cache the calculation results, and the effect is obvious

10. Let's have a look.
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750