0% found this document useful (0 votes)
23 views4 pages

Daily Quiz-2 - Accenture Pattern

The document describes two programming tasks: the first is to find a common digit among three three-digit integers, returning 1 if no common digit exists; the second task involves evaluating a binary string with operations represented by letters (A for AND, B for OR, C for XOR), returning the result of the operations. Each function has specific input formats and expected outputs, with examples provided for clarity. The document emphasizes the handling of edge cases such as null inputs and the structure of the binary string.

Uploaded by

anushya.himate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Daily Quiz-2 - Accenture Pattern

The document describes two programming tasks: the first is to find a common digit among three three-digit integers, returning 1 if no common digit exists; the second task involves evaluating a binary string with operations represented by letters (A for AND, B for OR, C for XOR), returning the result of the operations. Each function has specific input formats and expected outputs, with examples provided for clarity. The document emphasizes the handling of edge cases such as null inputs and the structure of the binary string.

Uploaded by

anushya.himate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Question 1.

Repeating Digit:
Implement the following function:
def CommonDigits(a,b,c):
The function accepts three positive integers a,b,c as its argument. Implement the function to
find and return the common digit in all three numbers if the no common digit then return 1.
Assumption:
All 3 numbers are three digit numbers
ABC numbers can have at most 1 digit common

Example:
Input:
a:426
b:486
c:652
output:
6
Explanation:
6 is common digit in all the three numbers, thus,6 is the output
The common input format for the above case:
426
486
652
(the first line represents a, the second line represents b,the third line represents c)
Question-2
Problem Description :
The Binary number system only uses two digits, 0 and 1 and number system can be called
binary string. You are required to implement the following function:
int OperationsBinaryString(char* str);
The function accepts a string str as its argument. The string str consists of binary digits
separated with an alphabet as follows:
– A denotes AND operation
– B denotes OR operation
– C denotes XOR Operation
You are required to calculate the result of the string str, scanning the string to right taking
one operation at a time, and return the same.

Note:
No order of priorities of operations is required
Length of str is odd
If str is NULL or None (in case of Python), return -1
Input:
str: 1C0C1C1A0B1
Output:
1

Explanation:
The alphabets in str when expanded becomes “1 XOR 0 XOR 1 XOR 1 AND 0 OR 1”, result
of the expression becomes 1, hence 1 is returned.

Sample Input:
0C1A1B1C1C1B0A0
Output:
0

You might also like