Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
8
Task/Entropy/Nim/entropy.nim
Normal file
8
Task/Entropy/Nim/entropy.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import tables, math
|
||||
|
||||
proc entropy(s): float =
|
||||
var t = initCountTable[char]()
|
||||
for c in s: t.inc(c)
|
||||
for x in t.values: result -= x/s.len * log2(x/s.len)
|
||||
|
||||
echo entropy("1223334444")
|
||||
Loading…
Add table
Add a link
Reference in a new issue