September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
31
Task/Fibonacci-word/Scilab/fibonacci-word-1.scilab
Normal file
31
Task/Fibonacci-word/Scilab/fibonacci-word-1.scilab
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
exec('.\entropy.sci',0);
|
||||
|
||||
function word=fiboword(n)
|
||||
word_1 = '1'; word_2 = '0';
|
||||
select n
|
||||
case 1
|
||||
word = word_1
|
||||
case 2
|
||||
word = word_2;
|
||||
case 3
|
||||
word = strcat([word_2 word_1]);
|
||||
else
|
||||
word = strcat([fiboword(n-1) fiboword(n-2)])
|
||||
end
|
||||
endfunction
|
||||
|
||||
final_length = 37;
|
||||
|
||||
N=[1:final_length]';
|
||||
char_length = zeros(N);
|
||||
entropies = zeros(N);
|
||||
tic();
|
||||
for i=1:final_length
|
||||
word = fiboword(i);
|
||||
char_length(i) = length(word);
|
||||
entropies(i) = entropy(word);
|
||||
end
|
||||
time = toc();
|
||||
|
||||
disp('EXECUTION TIME: '+string(time)+'s.');
|
||||
disp(['N', 'LENGTH', 'ENTROPY'; string([N char_length entropies])]);
|
||||
33
Task/Fibonacci-word/Scilab/fibonacci-word-2.scilab
Normal file
33
Task/Fibonacci-word/Scilab/fibonacci-word-2.scilab
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
exec('.\entropy.sci',0);
|
||||
|
||||
final_length = 37;
|
||||
|
||||
word_n = '';
|
||||
word_n_1 = '';
|
||||
word_n_2 = '';
|
||||
|
||||
N = [1:final_length]';
|
||||
word_length = zeros(N);
|
||||
entropies = zeros(N);
|
||||
|
||||
tic();
|
||||
for i = 1:final_length
|
||||
if i == 1 then
|
||||
word_n = '1';
|
||||
elseif i == 2
|
||||
word_n = '0';
|
||||
elseif i == 3
|
||||
word_n = '01';
|
||||
word_n_1 = '0';
|
||||
else
|
||||
word_n_2 = word_n_1;
|
||||
word_n_1 = word_n;
|
||||
word_n = word_n_1 + word_n_2;
|
||||
end
|
||||
word_length(i) = length(word_n);
|
||||
entropies(i) = entropy(word_n);
|
||||
end
|
||||
time = toc();
|
||||
|
||||
disp('EXECUTION TIME: '+string(time)+'s.');
|
||||
disp(['N', 'LENGTH', 'ENTROPY'; string([N word_length entropies])]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue