-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIncorrect_keyboard.c
68 lines (48 loc) · 1.94 KB
/
Incorrect_keyboard.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*Incorrect keyboard
Suman's keyboard got damaged as he dropped it from a considerable distance. As a result instead of K the keyboard may sometimes display T (but will never display K instead of T)
Similarly instead of G, the keyboard may sometimes display D, instead of R sometimes it may display L and sometimes instead of R it displays F.
Because of this Suman has to think of all possible words for a displayed word (obtained by typing using his keyboard). The program to be written should accept a word W which is displayed as a result of typing on Suman's keyboard and should calculate how many possible words it could mean (if typed using a properly working keyboard) and print the count as the output.
Boundary Conditions:
The length of the input word is between 2 and 100.
Input Format:
First line will contain the word W.
Output Format:
The count of possible words that the input word (typed using Suman's keyboard) could mean.
Sample Input/Output:
Example 1:
Input:
FILIPEK
Output:
4
Explanation:
The words that may be wrongly typed are F and L. Here F could be correctly typed or wrongly typed instead of R. Similarly L could be correctly typed or wrongly typed instead of R.
Hence the overall words to be considered are 2*2 = 4.
Note: K is not considered as K will not be typed instead of some other letter. Only instead of K sometimes T will be typed.
Example 2:
Input:
KICKED
Output:
2
Explanation:
D could be correctly typed or wrongly typed instead of G. Hence overall words to be considered = 2.
Example 3:
Input:
FUTILE
Output:
8
Explanation:
F,T,L - These three letters can be wrongly typed instead of R,K,R or can be correctly typed. Hence overall words to be considered = 2*2*2 = 8.
*/
#include<stdio.h>
#include<string.h>
int main(){
char str[200];
scanf("%s",str);
int len=strlen(str),i,p=1;;
for(i=0;i<len;i++){
if(str[i]=='F' || str[i]=='L' || str[i]=='D' || str[i]=='G' || str[i]=='T')
p*=2;
}
printf("%d",p);
return 0;
}