Create a list of 100 random strings of random length between 5 and 8 characters
ID: 2291137 • Letter: C
Question
Create a list of 100 random strings of random length between 5 and 8 characters and consisting of upper and lower case characters. Use the random functions that we discussed in class to create the strings. You can use the following to create a list of all upper and lower case letters. 3. Letters -[sorted(chr(c-x) for c in range(97,123) for x in (0,32))] 4. Using the list of strings created above, sort them based on the following criteria: a. b. c. The sum of the first three ASClI values in the string The length of the strings in reverse order The middle character of a string with odd length or the one closest to center on the left of it has even length Ex: 'today would use 'd', Thomas would use o'Explanation / Answer
clc;clear;
s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
for i=1:100
%find number of random characters to choose from
numRands = length(s);
%specify length of random string to generate
sLength = randi([3 5]);
%generate random string
randString{i}= s( ceil(rand(1,sLength)*numRands));
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.