Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Write a function, 22(inputString, minLetter), that takes as input a string of letters and returns six things: the lexicographically smallest letter (z/Z>y/Y>...>a/A) greater or

image text in transcribed

2. Write a function, 22(inputString, minLetter), that takes as input a string of letters and returns six things: the lexicographically smallest letter (z/Z>y/Y>...>a/A) greater or equal to minLetter, the smallest index at which that letter occurs, the third smallest letter greater than minLetter, the smallest index at which that letter occurs, the most common letter, and how many times the most common letter occurs. The third smallest letter must be distinct from the second smallest which must be distinct from the smallest. E.g. 'b' is the second smallest and 'd' is the third smallest in 'ababdc' Ignore case during computation. E.g. 'z' and 'Z' are considered the same letter. Use lower case when returning letters. Return None for smallest and thirdSmallest letters and corresponding indices when appropriate. You may not assume that the input string contains at least three different characters (or even any characters at all). Make sure to recognize various situations where fewer than three different letters appear in the string, and where there is no third smallest or smallest greater than minLetter. If two or more letters tie for most common, return the lexicographically smallest one. For example: >>> 92('aacyYcqyQQqyqc', 'b') ('c', 2, 'y', 3, 'q', 5) >>> 92('aacyYcqyQQqyqc', 'r') ('y', 3, None, None, 'q', 5) IMPORTANT NOTE: Use one or more simple loops, and simple comparison (,==, !=) operators only. You may use [] to access single characters of a string. You may not use built-in min, max, sort, or sorted functions (you should also not write your own sorting method). You may not use any built-in string methods other than lower). You may not use lists or dictionaries or the ord function. 2. Write a function, 22(inputString, minLetter), that takes as input a string of letters and returns six things: the lexicographically smallest letter (z/Z>y/Y>...>a/A) greater or equal to minLetter, the smallest index at which that letter occurs, the third smallest letter greater than minLetter, the smallest index at which that letter occurs, the most common letter, and how many times the most common letter occurs. The third smallest letter must be distinct from the second smallest which must be distinct from the smallest. E.g. 'b' is the second smallest and 'd' is the third smallest in 'ababdc' Ignore case during computation. E.g. 'z' and 'Z' are considered the same letter. Use lower case when returning letters. Return None for smallest and thirdSmallest letters and corresponding indices when appropriate. You may not assume that the input string contains at least three different characters (or even any characters at all). Make sure to recognize various situations where fewer than three different letters appear in the string, and where there is no third smallest or smallest greater than minLetter. If two or more letters tie for most common, return the lexicographically smallest one. For example: >>> 92('aacyYcqyQQqyqc', 'b') ('c', 2, 'y', 3, 'q', 5) >>> 92('aacyYcqyQQqyqc', 'r') ('y', 3, None, None, 'q', 5) IMPORTANT NOTE: Use one or more simple loops, and simple comparison (,==, !=) operators only. You may use [] to access single characters of a string. You may not use built-in min, max, sort, or sorted functions (you should also not write your own sorting method). You may not use any built-in string methods other than lower). You may not use lists or dictionaries or the ord function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions