Académique Documents
Professionnel Documents
Culture Documents
PART I :
1. Cell compete
There is a colony of 8 cells arranged in a straight line where each day every cell competes
with its adjacent cells(neighbour).
Each day, for each cell, if its neighbours are both active or both inactive, the cell becomes
inactive the next day,. otherwise itbecomes active the next day.
Assumptions:
The two cells on the ends have single adjacent cell, so the other adjacent cell can be assumsed
to be always inactive.
Even after updating the cell state. consider its pervious state for updating the state of other
cells. Update the cell informationof allcells simultaneously.
Write a fuction cellCompete which takes takes one 8 element array of integers cells
representing the current state of 8 cells and one integer days representing te number of
days to simulate.
An integer value of 1 represents an active cell and value of 0 represents an inactive cell.
program:
int* cellCompete(int* cells,int days)
{
//write your code here
}
//function signature ends
TESTCASES 1:
INPUT:
[1,0,0,0,0,1,0,0],1
EXPECTED RETURN VALUE:
[0,1,0,0,1,0,1,0]
TESTCASE 2:
INPUT:
[1,1,1,0,1,1,1,1,],2
EXPECTED RETURN VALUE:
[0,0,0,0,0,1,1,0]
3. Pangram Checking
Given a string check if it is Pangram or not. A pangram is a sentence containing every letter
in the English Alphabet.
Examples : The quick brown fox jumps over the lazy dog ” is a Pangram [Contains all the
characters from ‘a’ to ‘z’]
“The quick brown fox jumps over the dog” is not a Pangram [Doesn’t contains all the
characters from ‘a’ to ‘z’, as ‘l’, ‘z’, ‘y’ are missing]
We create a mark[] array of Boolean type. We iterate through all the characters of our
string and whenever we see a character we mark it. Lowercase and Uppercase are
considered the same. So ‘A’ and ‘a’ are marked in index 0 and similarly ‘Z’ and ‘z’ are
marked in index 25.
After iterating through all the characters we check whether all the characters are marked
or not. If not then return false as this is not a pangram else return true.
6.
6.
12. Write a function that accepts a sentence as a parameter, and returns the same with each
of its words reversed. The returned sentence should have 1 blank space between each pair
of words. Example:
Parameter: “jack and jill went up a hill”
Return Value: “kcaj dna llij tnew pu a llih”
17. ((()) If the no of open and closing braces match ok else print -1 ( matching Parenthesis )
1
2 2
333
4444
4444
333
22
1
Pattern program
1234
9 10 11 12
13 14 15 16
5678
1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1