Tuesday, February 13, 2024

 https://classroom.google.com/c/NjYzMTQwMzM1MTYx?cjc=4jfcjvo



George is very much interested in finding anagrams. One day, his professor gave him two strings S and C. George's task is to count the occurrences of anagrams of the string C in string S.


Write a program to help George to complete this task.

Input Format

The First line of input contains the string S.

The Next line contains the string C.


Refer to the sample input for formatting specifications.

Output Format

The Output prints the count of the occurrences of anagrams of the string C in string S.

Refer to the sample output for formatting specifications.

Constraints

1 <= |S| <= |C| <= 50

Sample 1 Input

forxxorfxdofr

for


Sample 1 Output


3

-----------------------------------------------------------------------------------------------------------------------------

IP Addresses

A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros.


For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses, but "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses.

Given a string s containing only digits, return all possible valid IP addresses that can be formed by inserting dots into s. You are not allowed to reorder or remove any digits in s. You may return the valid IP addresses in any order.


 


Example 1:


Input: s = "25525511135"

Output: ["255.255.11.135","255.255.111.35"]

Example 2:


Input: s = "0000"

Output: ["0.0.0.0"]

Example 3:


Input: s = "101023"

Output: ["1.0.10.23","1.0.102.3","10.1.0.23","10.10.2.3","101.0.2.3"]

 

----------------------------------------------------------------------------------------------------------------------------

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.


Symbol       Value

I             1

V             5

X             10

L             50

C             100

D             500

M             1000

For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.


Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:


I can be placed before V (5) and X (10) to make 4 and 9. 

X can be placed before L (50) and C (100) to make 40 and 90. 

C can be placed before D (500) and M (1000) to make 400 and 900.

Given an integer, convert it to a roman numeral.


 


Example 1:


Input: num = 3

Output: "III"

Explanation: 3 is represented as 3 ones.

Example 2:


Input: num = 58

Output: "LVIII"

Explanation: L = 50, V = 5, III = 3.

Example 3:


Input: num = 1994

Output: "MCMXCIV"

Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.

---------------------------------------------------------------------------------------------------------

Balanced Paranthesis

Given an expression string exp, write a program to examine whether the pairs and the orders of “{“, “}”, “(“, “)”, “[“, “]” are correct in the given expression.

 

Code:

#include <stdio.h>

#include <stdbool.h>

#include <string.h>

 

bool areBracketsBalanced(char s[],int n)

{

    int i = -1;

    char s1[n];

    for (int j = 0; j < n; j++) {

        if (s[j] == '(' || s[j] == '{' || s[j] == '[')

            s1[++i] = s[j];

        else {

            if (i >= 0

                && ((s1[i] == '(' && s[j] == ')')

                    || (s1[i] == '{' && s[j] == '}')

                    || (s1[i] == '[' && s[j] == ']')))

                i--;

            else

                return false;

        }

    }

    return i == -1;

}

 

int main()

{

    char s[100];

    scanf("%s",s);

    int n=strlen(s);

    if (areBracketsBalanced(s,n))

        printf("Balanced\n");

    else

        printf("Not Balanced\n");

   

    return 0;

}

 

----------------------------------------------------------------------------------------------------------------------------------------


Balanced Paranthesis

Given an expression string exp, write a program to examine whether the pairs and the orders of “{“, “}”, “(“, “)”, “[“, “]” are correct in the given expression.

 

Code:

#include <stdio.h>

#include <stdbool.h>

#include <string.h>

 

bool areBracketsBalanced(char s[],int n)

{

    int i = -1;

    char s1[n];

    for (int j = 0; j < n; j++) {

        if (s[j] == '(' || s[j] == '{' || s[j] == '[')

            s1[++i] = s[j];

        else {

            if (i >= 0

                && ((s1[i] == '(' && s[j] == ')')

                    || (s1[i] == '{' && s[j] == '}')

                    || (s1[i] == '[' && s[j] == ']')))

                i--;

            else

                return false;

        }

    }

    return i == -1;

}

 

int main()

{

    char s[100];

    scanf("%s",s);

    int n=strlen(s);

    if (areBracketsBalanced(s,n))

        printf("Balanced\n");

    else

        printf("Not Balanced\n");

   

    return 0;

}

 


---------------------------------------------------------------------------------------------------------------------------------------



String Replacement

Program Description

Take a string as input. The input string consists of numbers also. Generate a new string from the input string in such a way that the numbers in the string should be replaced by a character which is generated by considering the previous character in the following manner:

The new character is generated by adding the ascii value of previous character with the number and getting the character for the present location.

Example: If the previous character is a and the number is 9 then take the 9th character after a which is j and replace the number by j.

Sample Input 1

a4k3b2

Sample Output 1

aeknbd

Sample Input 2

a9x4z1

Sample Output 2

ajxbza

Sample Test Case 1

Input

a4k3b2

Output

aeknbd

 

Sample Test Case 2

Input

a9x4z1

Output

ajxbza

Hidden Test Case 1

Input

x4y3z2

Output

xbybzb

 

Hidden Test Case 2

Input

a2b5c9d8

Output

acbgcldl

 

Hidden Test Case 3

Input

a5d9i3t6y2a1

Output

afdmiltzyaab

Hidden Test Case 4

Input

c7r9a5z8y1

Output

cjraafzhyz

C Program

#include<stdio.h>

#include<string.h>

int main(){

          char s[1000];

          char s1[100];

          int i,n,j=0;

          s1[j]=0;

          scanf("%s",s);

          for(i=0;s[i]!='\0';i+=2){

                    if(isalpha(s[i])){

                              s1[j++]=s[i];

                              s1[j++]=(char)((s[i]-'a'+s[i+1]-'0')%26+97);

                    }                  

          }

          s1[j]='\0';

          printf("%s",s1);

          return 0;

}

JAVA Program

import java.io.*;

import java.util.*;

class Pattern

{

          public static void main(String args[])

          {

                    Scanner sc=new Scanner(System.in);

                    String s=sc.next();

                    char ch[]=s.toCharArray();

                    String result="";

                    for(int i=0;i<ch.length;i=i+2)

                    {

                              result=result+ch[i]+(char)((ch[i]-'a'+ch[i+1]-'0')%26+97);

 

                    }

                    System.out.println(result);

          }

}

Python Program

s=input()

res=""

for i in s:

    if i.isalpha():

        res+=i

        x=i

    else:

        d=chr((ord(x)-ord('a')+ord(i)-ord('0'))%26+97)

        res+=d

print(res)

 

-----------------------------------------------------------------------------------------------------------------------------

Run Length Decoding

Take a string as input. The string consists of a character succeeded by a number. Now you need to generate a new string as output in such a way that it is formed by repeating each character for the number of times it is succeeded by the given number.

Sample Input 1

a4b3c2

Sample Output 1

aaaabbbcc

Sample Input 2

a3b5

Sample Output 2

aaabbbbb

Hidden Test Case 1

Input

a5b3c2d1e2

Output

aaaaabbbccdee

Hidden Test Case 2

Input

j1a2g3

Output

jaaggg

Hidden Test Case 3

Input

T1r2a3i1n1i1n2g3

Output

Trraaaininnggg

C Program

#include<stdio.h>

#include<string.h>

int main(){

          char s[1000];

          char s1[100];

          int i,n,j=0;

          scanf("%s",s);

          for(i=0;s[i]!='\0';i+=2){

                    n=s[i+1]-'0';

                    while(n>0){

                              s1[j++]=s[i];

                              n--;

                    }

          }

          s1[j]='\0';

          printf("%s",s1);

          return 0;

}

JAVA Program

import java.util.*;

class Pattern1

{

          public static void main(String args[])

          {

                    Scanner sc=new Scanner(System.in);

                    String s=sc.next();

                    char ch[]=s.toCharArray();

                    String result="";

                    for(int i=0;i<ch.length;i=i+2)

                    {

                              int n=Integer.parseInt(ch[i+1]+"");

                              while(n>0)

                              {

                                        result=result+ch[i];

                                        n--;

                              }

                    }

                    System.out.println(result);

 

          }

}

 

Python Program

s=input()

result=""

for i in s:

    if i.isalpha():

        result+=i

        x=i

    else:

        d=int(i)

        newc=x*(d-1)

        result+=newc

print(result)

---------------------------------------------------------------------------------------------------------------------

Run Length Encoding

Take a string as input. The string consists of a character in succession. Now you need to generate a new string as output in such a way that it is formed by repeating each character followed by number of times it is repeated in the string in the order.

Sample Input 1

a4b3c2

aaaabbbcc

Sample Output 1

a4b3c2

Sample Input 2

aaabbbbb

Sample Output 2

a3b5

Hidden Test Case 1

Input

aaaaabbbccdee

Output

a5b3c2d1e2

Hidden Test Case 2

Input

jaaggg

Output

j1a2g3

Hidden Test Case 3

Input

Trraaaininnggg

Output

T1r2a3i1n1i1n2g3

 

 

Code:

#include <stdio.h>

#include<string.h>

#include<stdlib.h>

int main() {

   char str[100];

   scanf("%s",str);

   int len = strlen(str);

    char current_char = str[0];

    int count = 1;

    for (int i = 1; i <= len; i++) {

        if (str[i] == current_char) {

            count++;

        } else {

            printf("%c%d", current_char, count);

            current_char = str[i];

            count = 1;

        }

    }

 

    return 0;

}

---------------------------------------------------------------------------------------------------------------------------------------

Reverse String

Problem Description

Given a string as input you need to print the reverse of the words without reversing the characters. Example: If the given string is Aditya Engineering College then the program should print College Engineering Aditya

Sample Input 1

Technical Training

Sample Output 1

Training Technical

Sample Input 2

Aditya

Sample Output 2

Aditya

Hidden Test Case 1

Input

Information Technology

Output

Technology Information

Hidden Test Case 2

Input

Computer Science & Engineering

Output

Engineering & Science Computer

Hidden Test Case 3

Input

Lock down

Output

down Lock

Hidden Test Case 4

Input

A wise man once said not to go with intuition go with guts

Output

guts with go intuition with go to not said once man wise A

 

C Program

#include<stdio.h>

#include<string.h>

int main(){

 

    char str[100],text[100];

    int i=0,j=0;

    gets(str);

   

          while(str[i]!='\0')

                    i++;

          while(i>0){

         

                    text[j]=str[--i];

                    ++j;   

          }

          text[j]='\0';


    for(i=0;text[i]!='\0';i++){

       if(text[i+1]==' ' || text[i+1]==NULL){        

           for(j=i;j>=0 && text[j]!=' ';j--)

                              printf("%c",text[j]);

                    printf(" ");

          }      

    }

return 0;

}

JAVA Program

import java.util.regex.Pattern;

import java.util.*;

public class Exp {

      static String reverseWords(String str)

    {

  

        Pattern pattern = Pattern.compile("\\s");

  

        String[] temp = pattern.split(str);

        String result = "";

  

        for (int i = 0; i < temp.length; i++) {

            if (i == temp.length - 1)

                result = temp[i] + result;

            else

                result = " " + temp[i] + result;

        }

        return result;

    }

  

   

    public static void main(String[] args)

    {

        Scanner sc=new Scanner(System.in);

        String s1 = sc.next();

        System.out.println(reverseWords(s1));

  

    }

}

 

Python Program

S=input()

Words=S.split(“ “)

Sentence=” “.join(reversed(words))

print(Sentence)

 

 










---------------------------------------------------------------------------------------------------------------------------------------

Chain of pearls

Program Description

Saif likes kareena and he presented her a chain of pearls. The pearls are red and green in colors. Saif likes chains in which the red pearls and green pearls alternate each other i.e., R followed by G or G followed by R. So he wants to replace some of the pearls in the chain to suit his liking.

Let the red pearl be denoted as 'R' and let the green pearl be denoted as 'G'. For example  'RGRGRGR' is a Chain of Saif’s liking but  'RGTGRRG' is not. Help Saif to calculate the minimum number of pearls he need to replace (ex. 'R' to 'G' or 'G' to 'R') to get a chain that he would like.

Input Format
Input consists of a single string consisting of only the letters 'R' and 'G'.
Assume that the maximum length of the input string is 75.

Output Format
Output consists of a single interger - the minimal number of pearls that Saif need to replace.

Sample Input 1
RRRGRGRGGG

Sample Output 1
2

Sample Input 2
GGGGGGG

Sample Output 2:
3

Explanation
Example case 1.
We can change symbol 2 from 'R' to 'G' and symbol 9 from 'G' to 'R' and receive 'RGRGRGRGRG'.
Example case 2.
We can change symbols 2, 4 and 6 from 'G' to 'R' and receive 'GRGRGRG'.

Sample Test Case 1

Input

RRRGRGRGGG

Output

2

Sample Test Case 2

Input

GGGGGG

Output

3

Hidden Test Case 1

Input

RGRGRGRG

Output

0

Hidden Test Case 2

Input

GGGRRR

Output

2

Hidden Test Case 3

Input

RRRRGRGRGRRGRG

Output

6

Hidden Test Case 4

Input

RGRGRGGRGRGRGRGRGRGRGRGRRGRGRGGRGRRG

Output

14

C Program

#include<stdio.h>

#include<string.h>

int main(){

    char s[75];

    int i,n,count=0,x;

    scanf("%s",s);

    n=strlen(s);

    for(i=0;i<n;i++){

        if(i%2==0 && s[i]=='R'){

            count++;

        }

        else if(i%2==1 && s[i]=='G'){

            count++;

        }

    }

    if(count<n-count)

        x=count;

    else

        x=n-count;

    printf("%d\n",x);

    return 0;

}

JAVA Program

import java.io.*;

import java.util.*;

class Pearls{

    public static void main(String args[]){

        int i,n,count=0,x;

        Scanner sc=new Scanner(System.in);

        String s=sc.nextLine();

        n=s.length;

        for(i=0;i<n;i++){

            if(i%2==0 && s[i]=='R'){

                count++;

            }

            else if(i%2==1 && s[i]=='G'){

                count++;

            }

        }

        if(count<n-count)

            x=count;

        else

             x=n-count;

        System.out.println(x);

    }

}

Python Program

    s=input()

    count=0

    n=len(s)

    for i in range(n):

        if(i%2==0 && s[i]=='R'):

            count+=1

        else if(i%2==1 && s[i]=='G'):

            count+=1

    if(count<n-count):

        x=count

    else:

        x=n-count

    print(x)


------------------------------------------------------------------------------------------------------------------




Panagram String

Program Description

Given a string as input you need to determine whether the string is panagram or not. If the string is panagram print the string as “Panagram String.” Otherwise print “Not a Panagram String.”. A string is called panagram if it contains all the alphabets in english as the characters in it.

Note: The input string contains boh uppercase and lowercase characters in it.

Sample Input 1

ABcde fghIJkl MnopQr StuvWxyz

Sample Output 1

Panagram String.

Sample input 2

The five members of the team are so annoying.

Sample Output 2

Not a Panagram String.

Sample Test Case 1

Input

ABcde fghIJkl MnopQr StuvWxyz

Output

Panagram String.

Sample Test Case 2

Input

The five members of the team are so annoying.

Output

Not a Panagram String.

Hidden Test Case 1

Input

The five boxing wizards jump quickly.

Output

Panagram String.

Hidden Test Case 2

Input

The quick brown fox jumps over the lazy dog.

Output

Panagram String.

Hidden Test Case 3

Input

John quickly extemporized five tow bags.

Output

Panagram String

Hidden Test Case 4

Input

The Vixens of the hazardious grimp.

Output

Not a Panagram String.

C Program

#include<stdio.h>

#include<string.h>

void main()

{

    char s[100];

    int i,used[26]={0},total=0;

    gets(s);

    for(i=0;s[i]!='\0';i++)

    {

        if('a'<=s[i] && s[i]<='z')

        {

            total+=!used[s[i]-'a'];

            used[s[i]-'a']=1;

        }

        else if('A'<=s[i] && s[i]<='Z')

        {

            total+=!used[s[i]-'A'];

            used[s[i]-'A']=1;

        }

    }

    

    if(total==26)

    {

        printf("Panagram String.");

    }

    else

    {

        printf("Not a Panagram String.");

    }

    return 0;

}

JAVA Program

import java.io.*;

import java.util.*;

import java.text.*;

import java.math.*;

import java.util.regex.*;

 

public class Panagram {

 

    public static void main(String[] args) {

 

        Scanner scan = new Scanner(System.in);

        String sentence = scan.nextLine();

        sentence = sentence.toUpperCase();

        sentence = sentence.replaceAll("[^A-Z]", "");

 

        char[] chars = sentence.toCharArray();

 

        Set<Character> set = new HashSet<Character>();

 

        for( int i = 0; i < chars.length; i++ ) set.add(chars[i]);

 

        System.out.println(set.size() == 26 ? "Panagram String" : "Not a Pangram String");

 

    }

}

Python Program

import string

alpha=set(string.ascii_lowercase)

s=input()

if(set(s.lower())>=alpha):

    print("Panagram string")

else:

    print("Not a Panagram String")






------------------------------------------------------------------------------------------------------------------


String Occurence

Raja has been given 2 sentences. He needs to do a task with those 2 sentences. He needs to tell how many times the first sentence appeared in the second sentence which is called as the target along with the fist sentence. Help Raja in completing the task.

Input:

2 lines consists of 2 sentences

Constraints:

1<=s1,s2<=100

Output:

A single line consists of first sentence and the count of occurences of it in second sentence.

 

Sample Testcase1:

Input:

are

youareveryrarepicturearenowthare

Output:

are 4

 

Sample Testcase2:

Input:

is

thisisveryclearideaishowisyourhealthandisforthisnowtothis

Output:

is 7

 

Hidden Testcase1:

Input:

is

thisishowis

Output:

is 3

 

Hidden Testcase2:

Input:

are

therearearenoware

Output:

are 3

 

Hidden Testcase3:

Input:

for

formeforyouforeveryone

Output:

for 3

 

Hidden Testcase4:

Input:

ride

ridersgoingforarideanditsalongestrideofallrides

Output:

ride 4

 

C Code:

#include <stdio.h>

#include <string.h>

 

char str[100], sub[100];

int count = 0, count1 = 0;

 

void main()

{

    int i, j, l, l1, l2;

    scanf("%s%s", sub,str);

    l2 = strlen(sub);

   

 

    l1 = strlen(str);

   

    for (i = 0; i < l1;)

    {

        j = 0;

        count = 0;

        while ((str[i] == sub[j]))

        {

            count++;

            i++;

            j++;

        }

        if (count == l2)

        {

            count1++;                                  

            count = 0;

        }

        else

            i++;

    }   

    printf("%s %d", sub, count1);

}

Java Code:

import java.util.*;

class StringOccur

{

     public static void main(String args[])

          {

                     Scanner sc=new Scanner(System.in);

                     String s1=sc.next();

                     String s2=sc.next();

                     int l=s2.length();

                     int m=l- s2.replaceAll(s1,"").length();

                     System.out.println(s1+" "+(int)m/s1.length());

          }

}

Python Code:

pat=input()

text=input()

M = len(pat)

N = len(text)

res = 0

for i in range(N - M + 1):

    j = 0

    for j in range(M):

        if (text[i + j] != pat[j]):

            break

    if (j == M - 1):

        res += 1

        j = 0

print(pat,res)





------------------------------------------------------------------------------------------------------------------


String Anagrams

Sudeep is well known for his ability in coding in his college. A district wise coding competition is being held in the city. The competition allows the participants to take help from others if they are unable to solve it. Sudeep has taken his friend vijay. The task given in competition is like this: read two strings as an input. you need to check the number of times every character repeated in first string is exactly same as the number of times the same characters repeated in other string.  Then you need to print “YES” otherwise we need to print “NO”.  Now Sudeep asked vijay to do the task. Vijay is dazzled by seeing the code. Now you need to help vijay in solving the code so that they can go through further rounds.

Sample Testcase:

Input:

3

listen silent

liril river

top pot

Output:

YES

NO

YES

 

Sample Input:

2

Raja raj

ravi arvi

Output:

NO

YES

 

Testcase1:

Input:

4

funeral realfun

theeyes thaysee

agentleman elegantman

convers voices

Output:

YES

NO

YES

NO

 

Testcase2:

Input:

2

schoolmaster theclassroom

astronomer moonstarer

Output:

YES

YES

 

Testcase3:

Input:

3

ramu murali

raju arju

siva vikas

Output:

NO

YES

NO

 

Test Case 4:

Input:

4

sari rasi

send dens

settle seattle

jeera rajee

Output:

YES

YES

NO

YES


C Code:

#include<stdio.h>

#include<string.h>

int isnagram(char[],char[]);

int isanagram(char ch[],char ch1[]){

              int i,j,temp=0,temp1=0;

                    int n1=strlen(ch);

                    int n2=strlen(ch1);

                    if(n1!=n2){

                              return 0;

                    }

                    for(i=0;i<n1;i++){

                              for(j=i+1;j<n1;j++){

                              if(ch[i]>ch[j]){

                                        temp=ch[i];

                                        ch[i]=ch[j];

                                        ch[j]=temp;

                              }

                              if(ch1[i]>ch1[j]){

                                        temp1=ch1[i];

                                        ch1[i]=ch1[j];

                                        ch1[j]=temp1;

                              }

                    }

          }

          for(i=0;i<n1;i++){

                    if(ch[i]!=ch1[i]){

                              return 0;

                    }

          }

          return 1;

 

}

int main(){

          int t,i,j;

          scanf("%d",&t);

          for(i=0;i<t;i++){

                    char ch[100],ch1[100],temp=0,temp1=0;

                    scanf("%s%s",ch,ch1);

                    if(isanagram(ch,ch1)){

                              printf("YES\n");

                    }

                    else{

                              printf("NO\n");

                    }

          }

}

 

Java Code:

 

import java.util.*;

class Anagrams

{

          public static void main(String args[])

          {

                    Scanner sc=new Scanner(System.in);

                    int testcases;

                    testcases=sc.nextInt();

                    while(testcases-->0)

                    {

                    String s1,s2;

                    s1=sc.next();

                    s2=sc.next();

       

                    char ch1[]=s1.toCharArray();

                    char ch2[]=s2.toCharArray();

                   

                    Arrays.sort(ch1);

                    Arrays.sort(ch2);

 

                    if(Arrays.equals(ch1,ch2))

                              System.out.println("YES");

                    else

                              System.out.println("NO");

 

                    }

                    sc.close();

          }

}

 

 

Python Code:

 

def areAnagram(str1, str2): 

    n1 = len(str1) 

    n2 = len(str2) 

    if n1 != n2: 

        return 0

    str1 = sorted(str1)

    str2 = sorted(str2)

    for i in range(0, n1): 

        if str1[i] != str2[i]: 

            return 0

    return 1

 

t=int(input())

for i in range(t):

    str1 = input()

    str2 = input()

    if areAnagram(str1, str2): 

        print ("YES",end="\n")

    else: 

        print ("NO",end="\n")






------------------------------------------------------------------------------------------------------------------



Vowel Count

Raju is good at handling strings. Now Sasi has given a task to him. Sasi gives n number of strings to Raju. Now Raju has to find out the count of the number of vowels present in each string. Help Raju in completing the task.

Note: Characters will be in both upper and lowercase. So irrespective of case the count of vowel should be taken

Input:

N: Number of strings

Each Ni lines consists of a string

Constraints:

1<=N<=10

Output:

N lines each consists of count of vowels in each Nth string

Sample Test Case 1:

Input:

3

srinu

ramesh

aditya

Output:

2

2

3

Sample Test Case 2:

Input:

2

AdityA

SriAditya

Output:

3

4

Hidden Test Case 1:

Input:

5

adityaengineeringcollege

RaOgopAlRAO

MangO

Apple

Banana

Output:

11

6

2

2

3

 

Hidden Test Case 2:

Input:

2

adityagroupofengineeringcollegesarelocatedatsurampalemCAMPUSANDHRAPRADESH

YES

Output:

30

1

 

Hidden Test Case 3:

Input:

6

JagadEesh

SrInU

UDAYbhaskAr

VinayKumar

Vanathi

PrAvEeN

Output:

4

2

4

4

3

3

 

Hidden Test Case 4:

Input:

3

Arya

Ajith

Arun

Output:

2

2

2



C Code:

#include <stdio.h>

#include<string.h>

#include<stdlib.h>

int main()

{

  int c = 0, count = 0,n,i,j;

  scanf("%d",&n);

  char ch[n][100];

  for(i=0;i<n;i++){

             scanf("%s",ch[i]);

  }

  for(i=0;i<n;i++){

             count=0;

             for(j=0;j<100;j++){

             if(ch[i][j]=='a'||ch[i][j]=='A'||ch[i][j]=='e'||ch[i][j]=='E'||ch[i][j]=='i'||ch[i][j]=='I'||ch[i][j]=='o'||ch[i][j]=='O'||ch[i][j]=='u'||ch[i][j]=='U'){

                                      count++;

                          }

               }

               printf("%d\n",count);

    }

            

  return 0;

}

Java Code:

import java.util.*;

class VowelCount

{

             public static void main(String args[])

             {

                          Scanner sc=new Scanner(System.in);

                          int num,i,j,count=0;

                          String word,vowels="aeiouAEIOU";

                          char ch[];

                          num=sc.nextInt();

 

        for(i=0;i<num;i++)

                          {    count=0;

             word=sc.next();

                                       ch=word.toCharArray();

                                       for(j=0;j<ch.length;j++)

                                      {

                                                    if(vowels.contains(ch[j]+""))

                                                                 count++;

                                      }

                                      System.out.println(count);

                          }

             }

}

 

 

Python Code:

n=int(input())

a="aeiouAEIOU"

for i in range(n):

    s=input()

    count=0

    for i in s:

        if i in a:

            count+=1

    print(count)





------------------------------------------------------------------------------------------------------------------


String Equality

Sanath is a well versed student in the college. A new principal came to college and he gets to know about the knowledge of Sanath. He want’s to test Sanath and he has given a task like this: Given a sentence he needs to determine whether the string contains equal number of lowercase alphabets, upper case alphabets, digits and symbols. If so he needs to say “Equality For Everyone” otherwise he needs to say “No Equality”. Sanath wants to prove his ability to the new principal. So help Sanath.


Input:

A single line consisting of input sentence


Output:

A single line either display “Equality For Everyone” or “No Equality”


Sample Input 1:  

aB1$ 

Sample Output 1: 

Equality For Everyone 


Sample Input 2:  

ab23$% 

Sample Output 2: 

No Equality


Hidden Testcase 1:

Input:

a program to find the given string contains equal number of lowercase alphabets, upper case alphabets, digits and symbol123434023489274@#$%^!@#$%^(*&12345667897654333444

Output:

No Equality


Hidden Testcase 2:

Input:

abcd23$#,*46

Output:

No Equality





Hidden Testcase 3:

Input:

12ab32bc$#CB*^BC

Output:

Equality For Everyone


Hidden Test Case 4:

Input:

11223344aabbccddAABBCCDD$#$#$#$#

Output:

Equality For Everyone

















C Code:

#include<stdio.h>

#include<string.h>

int main(){

int l=0,u=0,d=0,s=0,i;

char x[1000];

scanf("%s",x);

for(i=0;x[i]!='\0';i++)

{

if(islower(x[i]))

l++;

else if(isupper(x[i]))

u++;

else if(x[i]>='0' && x[i]<='9')

d++;

else

s++;

}

if(l==u && u==d && d==s)

printf("Equality For Everyone");

else

printf("No Equality");


}

Java Code:

import java.util.*;

class Equality

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int l=0,u=0,d=0,s=0;

String str=sc.next();

char x[]=str.toCharArray();

for(int i=0;i<x.length;i++)

{

if(Character.isLowerCase(x[i]))

l++;

else if(Character.isUpperCase(x[i]))

u++;

else if(Character.isDigit(x[i]))

d++;

else

s++;

}

if(l==u && u==d && d==s)

System.out.println("Equality For Everyone");

else

System.out.println("No Equality");


}

}


Python Code:

s=input()

u=l=d=t=0

for i in s:

    if i.isupper():

        u+=1

    elif i.islower():

        l+=1

    elif i.isdigit():

        d+=1

    else:

        t+=1

if(l==u and u==d and d==t):

    print("Equality For Everyone")

else:

    print("No Equality")


  I/O Statements, Operators and Expressions 1- IO STATEMENTS 2 - CONDITIONAL STATEMENTS 3 - LOOPING CONSTRUCTS 4 - FUNCTIONS 5 - 1D ARRAY 6 ...