Question

In: Math

2. Non-Local Strings For this question, a block is a sequence of 20 characters, where each...

2. Non-Local Strings

For this question, a block is a sequence of 20 characters, where each character is one of the 26 lowercase letters a-z. For example, these are blocks:

iwpiybhunrplsovrowyt
rpulxfsqrixjhrtjmcrr
fxfpwdhwgxtdaqtmxmlf
  1. How many different blocks are there?
  2. A block is squarefree if no character appears two times consecutively. The first and third example above are squarefree, but the second example is not because of the two consecutive occurrences of r. How many squarefree blocks are there?
  3. A block is non-local if the number of characters between any two occurrences of the same character is at least 2. The first example above is non-local. The second example is not, because there are two occurrences of r with no characters between them. The third example is not because there are two occurrences of m with only one character between them. How many non-local blocks are there?
  4. A block is k-non-local if the number of characters between any two occurrences of the same character is at least k. Write a formula for the number of k-non-local blocks that is valid for any k∈{0,…,20}.

Sanity check: The formula you get for 2.4 gives the answer to 2.2 when k=1 and gives the answer to 2.3 when k=2.

Solutions

Expert Solution


Related Solutions

For this question, a block is a sequence of 20 characters, where each character is one...
For this question, a block is a sequence of 20 characters, where each character is one of the 26 lowercase letters a-z. For example, these are blocks: iwpiybhunrplsovrowyt rpulxfsqrixjhrtjmcrr fxfpwdhwgxtdaqtmxmlf How many different blocks are there? A block is squarefree if no character appears two times consecutively. The first and third example above are squarefree, but the second example is not because of the two consecutive occurrences of r. How many squarefree blocks are there? A block is non-local if...
A database uses 20-character strings as record identifiers. The valid characters in these strings are upper-case...
A database uses 20-character strings as record identifiers. The valid characters in these strings are upper-case letters in the English alphabet and decimal digits. (Recall there are 26 letters in the English alphabet and 10 decimal digits.) How many valid record identifiers are possible if a valid record identifier must meet all of the following criteria: Letter(s) from the set {A,E,I,O,U} occur in exactly three positions of the string. The last three characters in the string are distinct decimal digits...
Simon Says' is a memory game where 'Simon' outputs a sequence of 10 characters
Simon Says' is a memory game where 'Simon' outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Ex: The following patterns yield a userScore of 4:simonPattern: R, R, G, B, R, Y, Y, B, G, YuserPattern:  R, R, G, B, B,...
Question 1 A substring of String s is a sequence of k >= 0 characters in...
Question 1 A substring of String s is a sequence of k >= 0 characters in s, in the order in which they occur in s. The letters in a substring may be either contiguous (next to each other) or non-contiguous in the original String s. For instance, these are the substrings of String s="abc". String s All substrings of s ======== ================================== "abc" "" "a" "b" "ab" "c" "ac" "bc" "abc" Write a function allSubstrings that returns an ArrayList...
"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G,...
"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Assume simonPattern and userPattern are always the same length. Ex: The following patterns yield a userScore of 4: simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY #include <stdio.h>...
"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G,...
"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Ex: The following patterns yield a userScore of 4: simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY
A password is a sequence of five characters. Each character is one of twenty-six uppercase letters...
A password is a sequence of five characters. Each character is one of twenty-six uppercase letters (“A” through “Z”), one of ten digits (“0” through “9”), or one of five symbols (“+”, “-”, “!”, “<”, “>”). Count the number of possible passwords that can be created in each of the following scenarios. Consider each part of this questions separately. (a) There are no restrictions on how the characters are chosen. (b) A password must begin with a letter and end...
"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence.
For Java"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Ex: The following patterns yield a userScore of 4: simonPattern: R, R, G, B, R, Y, Y, B, G, Yimport java.util.Scanner;public class SimonSays...
6. A clay block and a steel block, each of mass 20 kg, sit on the...
6. A clay block and a steel block, each of mass 20 kg, sit on the edge of a frictionless table. The table is 120 cm high. A person throws a ball of mass 300 grams at each one at a speed of 30 m/s. The ball thrown at the clay block lodges inside it; the ball thrown at the steel block bounces off, traveling back in the direction that it came from at 20 m/s. Both blocks are knocked...
Please provide Python code that does the following: 2) A palindrome is any sequence of characters...
Please provide Python code that does the following: 2) A palindrome is any sequence of characters that reads the same backwards as forwards. One-word examples include: Dad madam rotor Kayak redder noon For the sake of this exercise, the following may also be considered one-word palindromes: 1881 zap4554paz That is, numeric strings and “nonsense” strings that read the same backwards as forwards should be classified as palindromes. Write a program that takes as input a string and determines if it’s...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT