String Programming Write a function called same pattern that returns true or false depending upon whether...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
String Programming Write a function called same pattern that returns true or false depending upon whether two strings have the same pattern of characters. More precisely, two strings have the same pattern if they are of the same length and if two characters in the first string are equal if and only if the characters in the corresponding positions in the second string are also equal. Below are some examples of patterns that are the same and patterns that differ (keep in mind that the method should return the same value no matter what order the two strings are passed). 1st String 2nd String Same Pattern? F "a" "a" "ab" "aa" "aba". "_" "abcabc" "abcabd" "abcabc" "aaassscccn" "asasasasas" "ascneencsa" "aaassscccn" "asasasasas" "ascneencsa" "aaassscccn" "aaasssiiii" "x" "ab" "ab" "xy" "+-+" "aba" "zodzod" "zodzoe" "XXXXXX" "aaabbbcccd" "xyxyxyxyxy" "aeiouuoiea" "aaabbbcccd" "xxxxxyyyyy" "aeiouaeiou" "xxxyyyzzzz" "gggdddfffh" True True False True False True False: True True False True True True True False False False False Your function should take two parameters: the two strings to compare. You are allowed to create new strings, but otherwise you are not allowed to construct extra data structures to solve this problem (no list, set, dictionary, etc). You are limited to the string functions on the cheat sheet. String Programming Write a function called same pattern that returns true or false depending upon whether two strings have the same pattern of characters. More precisely, two strings have the same pattern if they are of the same length and if two characters in the first string are equal if and only if the characters in the corresponding positions in the second string are also equal. Below are some examples of patterns that are the same and patterns that differ (keep in mind that the method should return the same value no matter what order the two strings are passed). 1st String 2nd String Same Pattern? F "a" "a" "ab" "aa" "aba". "_" "abcabc" "abcabd" "abcabc" "aaassscccn" "asasasasas" "ascneencsa" "aaassscccn" "asasasasas" "ascneencsa" "aaassscccn" "aaasssiiii" "x" "ab" "ab" "xy" "+-+" "aba" "zodzod" "zodzoe" "XXXXXX" "aaabbbcccd" "xyxyxyxyxy" "aeiouuoiea" "aaabbbcccd" "xxxxxyyyyy" "aeiouaeiou" "xxxyyyzzzz" "gggdddfffh" True True False True False True False: True True False True True True True False False False False Your function should take two parameters: the two strings to compare. You are allowed to create new strings, but otherwise you are not allowed to construct extra data structures to solve this problem (no list, set, dictionary, etc). You are limited to the string functions on the cheat sheet.
Expert Answer:
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these algorithms questions
-
Write a function called find_continents () which takes as parameterls: A dictionary in the format of the pokemon database as described in Q1 This function should construct and return a list of all...
-
Write a function called hms_to_secs() that takes three int values for hours, minutes, and secondsas arguments, and returns the equivalent time in seconds (type long). Function prototypes is given...
-
Write a function called riddle that returns a two line string, with a riddle and its answer. Modify makeHomePage to insert the riddle at the end of the page rather than the tagline.
-
The current auditor of CTT Company Limited (CTT), the largest property management group in Hong Kong, will resign after the nancial statements audit for the year ended 31 December 2021. Tony, a...
-
Find the heat flow during 30.0 days through a glass window of thickness 0.20 in. with area 15 ft2 if the average outer surface temperature is 25F and the average inner glass surface temperature is...
-
Explain the benefits of a residual income structure within an investment center framework. It may help to think of an example using an existing company.
-
Refer to the Arctic Springs Bottling Department Data Set. Complete Step 5 of the process costing procedure: Assign costs to units completed and to units in ending inventory. Arctic Springs produces...
-
Cortez Company is planning to introduce a new product that will sell for $96 a unit. The following manufacturing cost estimates have been made on 20,000 units to be produced the first year: Direct...
-
Draw energy band diagram for a MOS structure in thermal equilibrium with (a). P-type semiconductor. Use4 , 3.5 , 1.0m sc Gq eV q eV E eV = = = and calculate VFB. Estimate the required applied voltage...
-
1. Given the facts of the case, what communications do you believe Forrester & Loomis should have made with the audit committee with regard to the transactions with the vendor to comply with PCAOB AS...
-
Sutton Pond Apartments Inc.'s unadjusted and adjusted trial balance at April 30, 2020, follow: (Click the icon to view the unadjusted and adjusted trial balances.) Requirements 1. Make the adjusting...
-
The membership of Best Friends has changed over the years. Some of the people who started the group have moved on to other things while new members have found their place at Best Friends. Membership...
-
A situation that arose between Gena and Geoff on the set of Man of La Mancha illustrates the type of situation that often leads to tertiary tension. Gena had been in several plays and had studied...
-
Your class project group is facing serious schedule challenges. You have one month to complete a group report and present it to your class, but there is literally no way all five of you can meet at...
-
Two African American members of your group refer to each other as nigga when they greet each other at the beginning of group meetings. 4 You and one other member find the use of the term highly...
-
Your five-member class project group has been assigned to serve as consultants to another group. You are charged with observing this group, gathering data about it, evaluating the groups...
-
Martin Supply, Ltd. sells tents at a 4-person tent price of $250. Martin Supply purchases the tents from a supplier at a cost of $100 per tent. Last year the company sold 2,000 and generated...
-
Show that gj concave AHUCQ Abadie For nonnegative variables, we have the following corollary.
-
Write a loop that will create a new string that is the reverse of a given string.
-
Consider the following fragment of code: if (x > 5) System.out.println("A"); else if (x < 10) System.out.println("B"); else System.out.println("C"); What is displayed if x is a. 4; b. 5; c. 6; d. 9;...
-
Show the modifications needed to add exponentiation to the class Calculator in Listing 9.12. Use ^ to indicate the exponentiation operator and the method Math.pow to perform the computation. Listing...
-
Name three or more branches of Earth science, and describe the focus of each.
-
Where is lithosphere created? Where is it destroyed?
-
What are the large, interlocking pieces of lithosphere called?
Study smarter with the SolutionInn App