This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
func entropy(s) {
var counts = Hash.new;
s.each { |c| counts{c} := 0 ++ };
var len = s.len;
[0, counts.values.map {|count|
var freq = count/len; freq * freq.log2 }...
]«-»;
}
say entropy("1223334444");