Skip to main content

Programming Assignment-1: Holes


Let us assume paper as the plane and a letter as a curve on the plane, then each letter divides the plane into regions. For example letters "A", "D", "O", "P", "R" divide the plane into two regions so we say these letters each have one hole. Similarly, letter "B" has two holes and letters such as "C", "E", "F", "K" have no holes. We say that the number of holes in the text is equal to the total number of holes in the letters of the text. Write a program to determine how many holes are in a given text.

Input Format:
The only line contains a non-empty text composed only of uppercase letters of English alphabet.
Output Format:
output a single line containing the number of holes in the corresponding text.
Example-1

Input:


DRINKEATCODE

Output:

5

Explanation:

D R A O D has one hole hence total number of holes in the text is 5.

Source Code

ip=input()
c=0
H1=["A", "D", "O", "P", "R",'Q']
H0=['C','E','F','G','H','I','J','K','L','M','N','S','T','U','V','W','X','Y',"Z"]
for i in ip:
    if i in H1:
        c+=1
    elif i in H0:
        pass
    else:
        c+=2
print(c,end='') 

Comments

Popular posts from this blog

10 Best Bluetooth Speakers under 1000 range only in 2020

If you are looking best 10 bluetooth speakers in 2020 then this blog for you. Hi guys this is Santanu from Tech Pathsala. You are reading Tech Pathsala blog. So without wasting more time lets get started.  1.  boAt Stone 190F 5 W Bluetooth Speaker    Description These Bluetooth Speaker will help motivate you to complete various tasks with ease. It gives you an engaging sound experience with deep  bass feature. Long-lasting battery life and fast USB-C charging, you can enjoy using them for a long time without worrying about running out of  charge. Specifications General Sales Package:                     1x Stone 190, 1x Micro USB Charging                                                Cable, 1x User Manual Model Number:            ...

Top 5 Online Jobs Working from Home in 2020

I know you all have your own dreams and passion. But you are unable to follow your dreams and passion. There are some reasons Firstly ,  you think that " If you follow your dreams and passion then can you become a successful person in future ?" because you can't getting sufficient courage to make fulfill your dreams and passion. Secondly , "for some family reasons you are unable to follow your passion and dreams , am i right ?"  Without this two reasons you can have more reasons. But i suggest you that , you must follow your dreams and passion because you have interest on that. So , if you searching best online job working from home then this blog maybe help you. There are many scopes but, here i explain top 5 online jobs working from home.  Are you still reading ? then you have interest. So, hi this is Santanu from Tech Pathsala. You are reading Tech Pathsala blog. Without wasting more time lets get started. Table of contents Become a Freelancer Become a YouTub...

How to sum of two arrays in Python3:

Input Format: The first line of the input contains a number N representing the number of elements in array A. The second line of the input contains N numbers separated by a space. (after the last elements, there is no space) Output Format: Print the resultant array elements separated by a space. (no space after the last element) Example: Input: 4 2 5 3 1 Output: 3883 Explanation: Here array A is [1,2,3,4] and reverse of this array is [4,3,2,1] and hence the resultant array is [5,5,5,5]  SOURCE CODE: import math size=int(input()) list1=[] for x in input().split():   num=int(x)   list1=list1+[num]   for i in range(math.ceil(size/2)):     list1[i]=list1[size-1-i]=list1[i]+list1[size-1-i]     for i in range(size-1):       print(list1[i],end=" ")       print(list1[size-1],end="")