Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
alphabet = 'al';
table = {'1','010'};
compressed = [93,85,127];
assert(isequal(decode(compressed,table,alphabet),'laaalalalaaaaaaa'))
ans =
'laaalalalaaaaaaa'
|
2 | Pass |
alphabet = 'ehlo';
table = {'00','01','10','11'};
compressed = uint8([74 210 191]);
assert(isequal(decode(compressed,table,alphabet),'hellohellooo'))
ans =
'hellohellooo'
|
3 | Pass |
alphabet = ',.kcgIblowaisnufhe try';
table = {'000000','000001','00001','000100','000101','000110','000111','001','010','01100','01101','0111','1000','10010','10011','10100','10101','1011','110','1110','11110','11111'};
compressed = uint8([27 179 198 146 236 197 238 174 234 222 29 117 111 217 83 5 201 121 11 190 167 232 179 64 52 60 132 189 245 60 210 198 254 48 92 157 245 63 69 154 110 75 22 245 131 182]);
assert(isequal(decode(compressed,table,alphabet),'It is not worth the bother of killing yourself, since you always kill yourself too late. '))
ans =
'It is not worth the bother of killing yourself, since you always kill yourself too late. '
|
4 | Pass |
alphabet = char(randi(13)+96); alphabet=[alphabet alphabet+randi(13)];
table = {'1','010'};
n=randi(5)+2;
compressed = repmat([93,85,127],1,n);
assert(isequal(decode(compressed,table,alphabet),regexprep(regexprep(repmat('laaalalalaaaaaaa',1,n),'l',alphabet(2)),'a',alphabet(1)) ))
ans =
'vlllvlvlvlllllllvlllvlvlvlllllllvlllvlvlvlllllll'
|
5 | Pass |
compressed = char(randi(26,1,42)+96);
alphabet = unique(compressed);
compressed = uint8(compressed);
table = cellstr(dec2bin(alphabet,8));
assert(isequal(decode(compressed,table,alphabet), char(compressed)));
ans =
'dhdfkwplfblolhslmoixonjyoncnjcuqjtdfeshbpt'
|
Find all elements less than 0 or greater than 10 and replace them with NaN
13051 Solvers
1091 Solvers
Number of 1s in a binary string
2821 Solvers
Remove entire row and column in the matrix containing the input values
163 Solvers
192 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!