List of squares

List of squares. For a given integer N, print all the squares of integer numbers where the square is less than or equal to N, in ascending order. Test Case Input (N) Expected Output 1 10 1 4 9 2 20 1 4 9 16 3 30 1 4 9 16 25  

Delete every third character

Delete every third character. Given a string, remove all characters from it whose indices are divisible by 3. Test Case Input (String) Expected Output 1 abcdefghij bdefhij 2 0123456789 1245789 3 hello world el olrd  

Replace within the fragment

Replace within the fragment. Given a string, replace every occurrence of the letter “h” with the letter “H”, except for the first and the last occurrences. Test Case Input (String) Expected Output 1 hello heh hello HeH 2 hhhhhh hHHHh 3 ahoy ahoy  

Delete a character

Delete a character. Given a string, remove all occurrences of the character ‘@’. Test Case Input (String) Expected Output 1 hello@world helloworld 2 @python@is@awesome@ pythonisawesome 3 email@example.com emailexample.com  

Replace the substring

Replace the substring. Given a string, replace all occurrences of the number ‘1’ with the word ‘one’. Test Case Input (String) Expected Output 1 1 apple and 1 banana one apple and one banana 2 I have 1 dog and 1 cat I have one dog and one cat 3 1 is a number one …

Reverse the fragment

Reverse the fragment. Given a string in which the letter “h” occurs at least twice, reverse the sequence of characters enclosed between the first and last occurrences of “h”. Test Case Input (String) Expected Output 1 hellohehworld hellohheworld 2 hhhellohh hhhholleh 3 hehaheheho hehahheheo  

Remove the fragment

Remove the fragment. Given a string in which the letter “h” occurs at least twice, remove the first and last occurrence of the letter “h”, as well as all characters between them. Test Case Input (String) Expected Output 1 hellohehworld held 2 hhhellohh hh 3 hehaheheho ho  

The first and last occurrence

The first and last occurrence. Given a string that may or may not contain the letter “f”, print the index location of the first and last appearance of “f”. If the letter “f” occurs only once, print its index. If the letter “f” does not occur, do not print anything. Do not use loops in …

The second occurrence

The second occurrence. Given a string that may or may not contain the letter “f”, print the index location of the second occurrence of the letter “f”. If the string contains the letter “f” only once, print -1. If the string does not contain the letter “f”, print -2. Test Case Input (String) Expected Output …

To swap the two words

To swap the two words. Given a string consisting of exactly two words separated by a space, print a new string with the positions of the first and second words swapped (i.e., the second word is printed first). Test Case Input (String) Expected Output 1 Hello World World Hello 2 Good Morning Morning Good 3 …