uwu part 1: Define a string containing the characters uwu as an adorable string. When testing...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
uwu part 1: Define a string containing the characters "uwu" as an adorable string. When testing a string for adorability, it does not matter whether or not the characters u, w, and u appear side-by-side, so long as they appear in that order. "uwu" is an adorable string, as is "uwuwu", but "wuu" and "uuw" are not adorable strings. Also, though, "uxwxu" is considered an adorable string, since although the characters u, w, and u are separated by the character 'x', they still appear in the string in the proper order. Strings count as adorable regardless of the case of the characters: "UwU" is adorable, as are "uWu" and "UWu". Write a program that reads a file containing a string on each line, and prints: ● How many strings are in the file How many of these strings are adorable The adorability value of the file as a whole, expressed as a floating-point number between 0 and 1. For example, if 7 out of 10 strings in the file are adorable, the adorability value of the file is 0.7 ● ● Follow the output format below exactly: There are [total count of strings in the file] lines in the file [filename] [count of adorable strings] of these lines are adorable. The adorability value of [filename] is [adorability value] uwu Part 2: Define the adorability count of a string as the number of occurrences of u, w, and u in that order in the string. The string "uwu" has an adorability count of 1, the string "OwO" has an adorability count of 0, and the string "did you watch naruto?" has an adorability count of 1, because the letters u, w, and u appear in that order. However, the string "do you want to run like naruto?" has an adorability count of 2: the first occurrence of uwu consists of the u in "you", the w in "want", and the u in "run", while the second occurrence of uwu consists of the u in "you", the w in "want", and the u in "naruto". The string "uwu uwu" has an adorability count of 6. I've indicated each adorable substring with underlines: uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu Write a function that takes a single string as input, then returns its adorability count. NOTE: this part is far and away the most difficult part of the problem. Write out your strategy on paper and step through it (pretend you're the computer) before you try to implement it in code. Verify to the best of your abilities that your solution is indeed correct. If you try to write this in C++ without thoroughly verifying your algorithm on paper first, you will almost certainly not be able to find a valid solution. There are both recursive and iterative solutions to this question. I used a recursive solution, but you don't have to. NOTE: the methods you develop to detect adorability can be used for much more serious purposes. I first encountered this problem in the context of finding particular strings of DNA in a genome. uwu Part 3: Using your function from part 2, write a program that asks the user for a filename, opens that filename, and prints the following information about the file: ● How many strings are in the file How many of these strings are adorable The adorability proportion of the file. The most adorable string in the file. Adorability proportion consists of the total adorability count of all lines in the file, divided by the number of lines. Represent the adorability proportion as a floating-point number. Because lines can have an adorability count of more than 1, it is possible for the adorability proportion to be greater than 1. For example, a file containing the following lines: uwu wha???? uwuuu has an adorability proportion of 1.33. There are three lines, the first line has an adorability count of 1, the second line has an adorability count of 0, and the third line has an adorability count of 3. Therefore, the total adorability count of the file is 4, the total number of lines in the file is 3, and so the adorability proportion is 4/3, or 1.333. Match the output format below exactly: There are [total count of strings in the file] lines in the file [filename] [count of adorable strings] of these lines are adorable. The adorability proportion of [filename] is [adorability proportion] The most adorable line is [text of the line with the highest adorability count] Extra credit for developing extremely efficient methods of determining string adorability (though full credit given for any working method, no matter how inefficient). uwu part 1: Define a string containing the characters "uwu" as an adorable string. When testing a string for adorability, it does not matter whether or not the characters u, w, and u appear side-by-side, so long as they appear in that order. "uwu" is an adorable string, as is "uwuwu", but "wuu" and "uuw" are not adorable strings. Also, though, "uxwxu" is considered an adorable string, since although the characters u, w, and u are separated by the character 'x', they still appear in the string in the proper order. Strings count as adorable regardless of the case of the characters: "UwU" is adorable, as are "uWu" and "UWu". Write a program that reads a file containing a string on each line, and prints: ● How many strings are in the file How many of these strings are adorable The adorability value of the file as a whole, expressed as a floating-point number between 0 and 1. For example, if 7 out of 10 strings in the file are adorable, the adorability value of the file is 0.7 ● ● Follow the output format below exactly: There are [total count of strings in the file] lines in the file [filename] [count of adorable strings] of these lines are adorable. The adorability value of [filename] is [adorability value] uwu Part 2: Define the adorability count of a string as the number of occurrences of u, w, and u in that order in the string. The string "uwu" has an adorability count of 1, the string "OwO" has an adorability count of 0, and the string "did you watch naruto?" has an adorability count of 1, because the letters u, w, and u appear in that order. However, the string "do you want to run like naruto?" has an adorability count of 2: the first occurrence of uwu consists of the u in "you", the w in "want", and the u in "run", while the second occurrence of uwu consists of the u in "you", the w in "want", and the u in "naruto". The string "uwu uwu" has an adorability count of 6. I've indicated each adorable substring with underlines: uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu Write a function that takes a single string as input, then returns its adorability count. NOTE: this part is far and away the most difficult part of the problem. Write out your strategy on paper and step through it (pretend you're the computer) before you try to implement it in code. Verify to the best of your abilities that your solution is indeed correct. If you try to write this in C++ without thoroughly verifying your algorithm on paper first, you will almost certainly not be able to find a valid solution. There are both recursive and iterative solutions to this question. I used a recursive solution, but you don't have to. NOTE: the methods you develop to detect adorability can be used for much more serious purposes. I first encountered this problem in the context of finding particular strings of DNA in a genome. uwu Part 3: Using your function from part 2, write a program that asks the user for a filename, opens that filename, and prints the following information about the file: ● How many strings are in the file How many of these strings are adorable The adorability proportion of the file. The most adorable string in the file. Adorability proportion consists of the total adorability count of all lines in the file, divided by the number of lines. Represent the adorability proportion as a floating-point number. Because lines can have an adorability count of more than 1, it is possible for the adorability proportion to be greater than 1. For example, a file containing the following lines: uwu wha???? uwuuu has an adorability proportion of 1.33. There are three lines, the first line has an adorability count of 1, the second line has an adorability count of 0, and the third line has an adorability count of 3. Therefore, the total adorability count of the file is 4, the total number of lines in the file is 3, and so the adorability proportion is 4/3, or 1.333. Match the output format below exactly: There are [total count of strings in the file] lines in the file [filename] [count of adorable strings] of these lines are adorable. The adorability proportion of [filename] is [adorability proportion] The most adorable line is [text of the line with the highest adorability count] Extra credit for developing extremely efficient methods of determining string adorability (though full credit given for any working method, no matter how inefficient).
Expert Answer:
Answer rating: 100% (QA)
I have attached the functions along with a driver program to test the program The code is fairly sim... View the full answer
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date:
Students also viewed these electrical engineering questions
-
In C program language 1. Triplet Prodigies: Write a C program called lastname Triplets that accepts any number of integers. The program (parent process =P) should create 3 children, C1, C2, and C3,...
-
A language L is complete for a language class C with respect to polynomial-time reductions if L C and L P L for all L C. Show that ; and {0, 1} * are the only languages in P that are not complete...
-
Design and develop programs using assembly language and C language to gain insight into instructions of microprocessors and microcontrollers. Write down a assembly language implementation to move a...
-
Write a short email to your instructor, discussing what you believe are your greatest strengths and weaknesses from an employment perspective. Next, explain how these strengths and weaknesses would...
-
When might an investment bank decline participation in an underwriting and why?
-
What is the theoretical justification for a so-called Laffer curve? Based on the empirical evidence described in the text, should the U.S. raise or lower its tax rates in order to increase tax...
-
The following is the distribution of the daily number of power failures reported in a western city on 300 days: Test at the 0.05 level of significance whether the daily number of power failures in...
-
Using the following data, compute the debt ratio. Accounts Payable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $ 3,500 Accounts Receivable. . ....
-
You (and your team) are employed as Management Accountants working for Qantas Airways. You have been given the task of recommending a new business strategy for Qantas Airways. Question 1 1. Using...
-
Assume that on January 1, 2013, the investor company issued 4,000 new shares of the investor company's common stock in exchange for all of the individually identifiable assets and liabilities of the...
-
Suppose that you deposit $2,000 today in account paying simple interest of 8% annually. How much interest will you have earned at the end of 10 years? Round your final answer to two decimals.
-
What will be the output of the following C++ code? * #include using namespace std; void fun(int, int); main() { int x = 10; fun(x, x); } cout < < x; void fun(int x, int y) { x = 20; } y = 10;
-
a. 4b. Draw a free body diagram and write a governing equation for y in the system below. Let y = 0 when the spring is relaxed, and assume that gravity acts in the -y direction. By f(t) m k B Suppose...
-
If the walt disney company decides to use actvitiy based costing ( ABC ) , what are some actvitiy bases ( cost drivers ) it might use to allocate these costs?
-
John and Holly are married and file a joint tax return. They have taxable income of $ 9 0 , 0 0 0 . Holly has an opportunity to earn an additional $ 1 0 0 . What is their marginal tax rate on the...
-
Valerie left a gross estate valued at $2,350,675. She left everything to her husband, Theodore. The estate administration expenses are $70,000, the debts are $155,000, and funeral expenses are...
-
COVID-19 has generated significant instability and high volatility in global capital markets. The financial sector has been one of the most affected, with bank valuations dropping in all countries...
-
Software Solution is family-owned business that has been in operation for more than 15 year. The board of directors is comprised of mainly family members, plus a few professionals such as an...
-
Moral Hazard versus Adverse Selection in Health Care Reform: We mentioned moral hazard only brieflyand primarily in the context of how this might aggravate the adverse selection problem. In this...
-
Suppose there are three possible candidates that might run for office, and each has to decide whether or not to enter the race. Assume the electorates ideal points can be defined by the Hotel ling...
-
Sometimes we can infer something about tastes from observing only two choices under two different economic circumstances. A. Suppose we consume only beer and pizza (sold at prices p1 and p2...
-
Most countries in Europe do not have stringent laws to protect whistleblowers. True/false
-
In view of significant financial losses to investors, corporate fraud does not really affect the U.S. economy and investor confidence. True/false
-
Auditors should not demand full access to the entire general ledger so that they can be more focused on the audit. True/false
Study smarter with the SolutionInn App