Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

uwu part 1: Define a string containing the characters uwu as an adorable string. When testing a string for adorability, it does not matter

imageimage


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).

Step by Step Solution

3.41 Rating (148 Votes )

There are 3 Steps involved in it

Step: 1

I have attached the functions along with a driver program to test the program The code is fairly sim... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Electrical Engineering questions

Question

=+a) Is this an observational or experimental study?

Answered: 1 week ago

Question

What is the meaning and definition of E-Business?

Answered: 1 week ago