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
22
Task/Fibonacci-word/Sidef/fibonacci-word.sidef
Normal file
22
Task/Fibonacci-word/Sidef/fibonacci-word.sidef
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
func entropy(s) {
|
||||
[0] + (s.chars.freq.values »/» s.len) -> reduce { |a,b|
|
||||
a - b*b.log2
|
||||
}
|
||||
}
|
||||
|
||||
var n_max = 37
|
||||
var words = ['1', '0']
|
||||
|
||||
{
|
||||
words.append(words[-1] + words[-2])
|
||||
} * (n_max - words.len)
|
||||
|
||||
say ('%3s %10s %15s %s' % <N Length Entropy Fibword>...)
|
||||
|
||||
for i in ^words {
|
||||
var word = words[i]
|
||||
say ('%3i %10i %15.12f %s' % (i+1,
|
||||
word.len,
|
||||
entropy(word),
|
||||
word.len<30 ? word : '<too long>'))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue