tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
12
Task/Pangram-checker/MATLAB/pangram-checker-1.m
Normal file
12
Task/Pangram-checker/MATLAB/pangram-checker-1.m
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function trueFalse = isPangram(string)
|
||||
|
||||
%This works by histogramming the ascii character codes for lower case
|
||||
%letters contained in the string (which is first converted to all
|
||||
%lower case letters). Then it finds the index of the first letter that
|
||||
%is not contained in the string (this is faster than using the find
|
||||
%without the second parameter). If the find returns an empty array then
|
||||
%the original string is a pangram, if not then it isn't.
|
||||
|
||||
trueFalse = isempty(find( histc(lower(string),(97:122))==0,1 ));
|
||||
|
||||
end
|
||||
5
Task/Pangram-checker/MATLAB/pangram-checker-2.m
Normal file
5
Task/Pangram-checker/MATLAB/pangram-checker-2.m
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
isPangram('The quick brown fox jumps over the lazy dog.')
|
||||
|
||||
ans =
|
||||
|
||||
1
|
||||
5
Task/Pangram-checker/MATLAB/pangram-checker.m
Normal file
5
Task/Pangram-checker/MATLAB/pangram-checker.m
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
function trueFalse = isPangram(string)
|
||||
% X is a histogram of letters
|
||||
X = sparse(abs(lower(string)),1,1,128,1);
|
||||
trueFalse = full(all(X('a':'z') > 0));
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue