Orpheus, a well known artist, and artist intends to quiet Cerberus with his verse and securely stroll past him. He made an extremely unconventional sonnet for Cerberus. It comprises just of lowercase English letters.    We consider a sonnet's substring a palindrome if

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

Orpheus, a well known artist, and artist intends to quiet Cerberus with his verse and securely stroll past him. He made an extremely unconventional sonnet for Cerberus. It comprises just of lowercase English letters. 

 

We consider a sonnet's substring a palindrome if and provided that it peruses the equivalent in reverse and advances. A string a will be a substring of a string b if a can be acquired from b by erasing a few (conceivably zero or all) characters from the start and a few (perhaps zero or all) characters from the end. 

 

Shockingly, Cerberus loathes palindromes of length more prominent than 1. For instance in the sonnet abaa the dog of Hades wouldn't care for substrings aba and aa. 

 

Orpheus can possibly quiet Cerberus if the dog loves his verse. That is the reason he needs to change his sonnet so it doesn't contain any palindrome substrings of length more prominent than 1. 

 

Orpheus can alter the sonnet by supplanting a letter at any situation with any lowercase English letter. He can utilize this activity discretionarily commonly (perhaps zero). Since there can be numerous palindromes in his sonnet, he might need to make a few amendments. Be that as it may, what number of, precisely? Given the sonnet, decide the insignificant number of letters that must be changed so the sonnet doesn't contain any palindromes of length more prominent than 1. 

 

Input 

 

The main line of the input contains a solitary integer t (1≤t≤105) signifying the number of experiments, then, at that point, t experiments follow. 

 

The sole line of each experiment contains a non-void line of lowercase English letters, Orpheus' sonnet. 

 

The amount of the length of Orpheus' sonnets in all experiments won't surpass 105. 

 

Output 

 

You should output t lines, I-th line ought to contain a solitary integer, reply to the I-th experiment.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Boolean Algebra and Digital Logics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education