A company has launched a new text editor that allows users to enter English letters, numbers and whitespaces only. If a user attempts to enter any other type of character, it is counted as a miss. Given a string of text, write an algorithm to help the developer detect the number of misses by a given user in the given input.
Input
The input consists of a string textinput, representing the text that is entered in the text editor by the user.
Output
Print an integer representing the number of misses by a given user in the given input.
Example
Input:
aa a234bc@ sads hsagd^
Output:
3
Explanation:
The characters that are counted as misses by the editor are l’@’s.]
Solution
def editorMisses(textinput):
count = 0
for i in textinput:
if i.isalpha() == False and i.isdigit() == False and i.isspace() == False:
count += 1
return count public static int editorMisses(String input) {
int miss = 0;
for (int i = 0; i < input.length(); i++) {
if (!Character.isLetterOrDigit(input.charAt(i)) && !Character.isWhitespace(input.charAt(i))) {
miss++;
}
}
return miss;
}Happy Learning – If you require any further information, feel free to contact me.
![[Solved] A company has launched a new text editor that allows users to enter English letters [Solved] A company has launched a new text editor that allows users to enter English letters](https://realcoder.techss24.com/wp-content/uploads/2022/11/Solved-A-company-has-launched-a-new-text-editor-that-allows-users-to-enter-English-letters.png)
![[Solved] Find the number of marbles in the missing bowl](https://realcoder.techss24.com/wp-content/uploads/2022/11/Solved-Find-the-number-of-marbles-in-the-missing-bowl-300x199.png)
![[Solved] Lucky Numbers STARTERS 73 CodeChef](https://realcoder.techss24.com/wp-content/uploads/2023/01/Solved-Lucky-Numbers-STARTERS-73-CodeChef-300x200.png)
![[Solved] Maximizing LCS STARTERS 71 CodeChef](https://realcoder.techss24.com/wp-content/uploads/2022/12/Solved-Maximizing-LCS-STARTERS-71-CodeChef-300x196.png)