id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

UIL2015_INVA_04_CONSONANTRUNS


Given a string, find the longest run of consonants, case insensitive and which may or may not be consecutive, that are either ascending or descending. In this problem the letter “Y” is a consonant. The following consonants are ascending – “b g t”. The following consonants are descending – “m h c”. Repeated consonants can be considered ascending when determining ascending runs and descending when considering descending runs. A string of a single consonant can be considered either ascending or descending.

For example, in the string "A human must turn information into intelligence or knowledge." the consonants are:

h m n m s t t r n n f r m t n n t n t l l g n c r k n w l d g

Excluding shorter substrings, the ascending runs are

hmn, mstt, r, nn, fr, mt, nnt, nt, ll, gn, cr, knw, dg

and the descending runs are

nm, ttrnnf, rm, tnn, tn, tllg, nc, rk, wld, g

The string ttrnnf is the longest ascending or descending string, thus the longest run is 6.

Input
Each input will consist of a string between 1 and 128 characters long, inclusive. The string may be a mix of uppercase and lowercase letters, digits, punctuation marks, and spaces.

Output
For each input string, return a single integer representing the count of the longest run of ascending or descending consonants in the string.


UIL2015_INVA_04_CONSONANTRUNS("QWERTY") → 3
UIL2015_INVA_04_CONSONANTRUNS("Human") → 3
UIL2015_INVA_04_CONSONANTRUNS("A human must turn information into intelligence or knowledge.") → 6

...Save, Compile, Run (ctrl-enter)

public int UIL2015_INVA_04_CONSONANTRUNS(String s) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy