Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Description There are a lot of horses in the yard, and we want to count how many there are. Unfortunately, we've only got a

Problem Description

There are a lot of horses in the yard, and we want to count how many there are. Unfortunately, we've only got a recording of the sounds from the yard. All the horses say "neigh". The problem is they can "neigh" many times. The recording from the yard is sadly all mixed together. So, we need to figure out from the overlapping sounds how many horses there could be.

For example, we've got two horses in the yard, and we hear this "neigneighh". From this recording, we can successfully deduce there are 2 horses. Another example is "neighneigh". From this example, we can only tell there is one horse in the yard.

As an additional complexity, our recording might not be perfect. If it's a bad recording, we should give "Invalid" as the response.

The input will be given as a string on one line. The output should be printed on it's own line.

Sample Input

nenigehnieighgh

Sample Output

2

code:

import sys

line = sys.stdin.readline() print(line)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

7. How will you encourage her to report back on the findings?

Answered: 1 week ago

Question

Were the decisions based on appropriate facts?

Answered: 1 week ago

Question

Were the right people involved in the decision-making process?

Answered: 1 week ago