0% found this document useful (0 votes)
349 views

Assignment 5 - Strings

The document outlines 10 string manipulation tasks: 1) check if a string is a palindrome, 2) count palindromic substrings, 3) toggle character cases, 4) replace odd and even characters with ASCII-adjacent characters, 5) insert ASCII differences between characters, 6) print all subsequences, 7) print all permutations, 8) find most frequent character, 9) remove consecutive duplicates, and 10) perform basic string compression. For each task, the user is prompted to take a string as input and write a function to perform the task, printing the output.

Uploaded by

MRINAAL GOSAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
349 views

Assignment 5 - Strings

The document outlines 10 string manipulation tasks: 1) check if a string is a palindrome, 2) count palindromic substrings, 3) toggle character cases, 4) replace odd and even characters with ASCII-adjacent characters, 5) insert ASCII differences between characters, 6) print all subsequences, 7) print all permutations, 8) find most frequent character, 9) remove consecutive duplicates, and 10) perform basic string compression. For each task, the user is prompted to take a string as input and write a function to perform the task, printing the output.

Uploaded by

MRINAAL GOSAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1

Assignment 5 - Strings
1. Take as input S, a string. Write a function that returns true if the string is a
palindrome and false otherwise. Print the value returned.
2. Take as input S, a string. Write a function that returns the count of substrings of this
string which are palindromes. Print the value returned.
3. Take as input S, a string. Write a function that toggles the case of all characters in
the string. Print the value returned.
4. Take as input S, a string. Write a function that replaces every odd character with
the character having just higher ascii code and every even character with the
character having just lower ascii code. Print the value returned.
5. Take as input S, a string. Write a function that inserts between each pair of
characters the difference between their ascii codes. Print the value returned.
6. Take as input S, a string. Write a function that prints all its subsequences.
7. Take as input S, a string. Write a function that prints all its permutations.
8. Take as input S, a string. Write a function that returns the character with
maximum frequency. Print the value returned.
9. Take as input S, a string. Write a function that removes all consecutive duplicates.
Print the value returned. E.g. for input "aabccba" print "abcba".
10. Take as input S, a string. Write a function that does basic string compression. Print
the value returned. E.g. for input “aaabbccds” print out a3b2c2ds.

You might also like