Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Entropy/PureBasic/entropy.basic
Normal file
22
Task/Entropy/PureBasic/entropy.basic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#TESTSTR="1223334444"
|
||||
NewMap uchar.i() : Define.d e
|
||||
|
||||
Procedure.d nlog2(x.d) : ProcedureReturn Log(x)/Log(2) : EndProcedure
|
||||
|
||||
Procedure countchar(s$, Map uchar())
|
||||
If Len(s$)
|
||||
uchar(Left(s$,1))=CountString(s$,Left(s$,1))
|
||||
s$=RemoveString(s$,Left(s$,1))
|
||||
ProcedureReturn countchar(s$, uchar())
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
countchar(#TESTSTR,uchar())
|
||||
|
||||
ForEach uchar()
|
||||
e-uchar()/Len(#TESTSTR)*nlog2(uchar()/Len(#TESTSTR))
|
||||
Next
|
||||
|
||||
OpenConsole()
|
||||
Print("Entropy of ["+#TESTSTR+"] = "+StrD(e,15))
|
||||
Input()
|
||||
Loading…
Add table
Add a link
Reference in a new issue