Coding Questions 2 - Accenture
Coding Questions 2 - Accenture
-------------------------------------------------------------------------------------------------------------
01. There is a tournament in town. The rule of the game is such that the player with the highest number of
goals wins. Three players compete at a time. The committee needs a program to determine the winner based
on the highest number of goals scored. Write a program and help the committee to declare the winner with
highest number of goals.
Example
Input: 15 20 22
Output: The largest number is: 22
Input: 25 55 62
Output: The largest number is: 62
Please compile the code once in order to save it. Navigating to another question without it will result in losing
the code.
--------------------------------------------------------------------------------------------------------------------------------------------------
02. In English class there is a boy named Hamid. He has little bit problem in writing long words. For eg. some
words like "localization" or "internationalization" are so long that writing them many times in one text is quite
tiresome.
So his friend couldn't able to see him like that and find out a technique which was so useful for him. So first he
calorized the word largest as which having size greater than 10.
So whenever Hamid came across the word which is largest perform certain steps. He'll write down the first
and the last letter of a word and between them he have to write the number of letters between the first and
the last letters.
Thus, "localization" will be spelt as "110n", and "internationalization>> will be spelt as "118n".
The first line contains an string s (1≤s≤100).
Print the string which should contain the result of replacing of the i-th word from the input data.
Please compile the code once in order to save it. Navigating to another question without compiling it will
result in losing the code.
--------------------------------------------------------------------------------------------------------------------------------------------------
03. There is a tournament in town. The rule of the game is such that the player with the highest number of
goals wins: Three players compete at a time. The committee needs a program to determine the winner based
on the highest number of goals scored. Write a program and help the committee to declare the winner with
highest number of goals
Example 1:
Input: 15 20 22
Output: The largest number is 22
Input: 25 55 62
Output: The largest number is: 62
Please compile the code once in order to save it. Navigating to another question Without compiling it will
result in losing the code
--------------------------------------------------------------------------------------------------------------------------------------------------
04. Problem Statement: Find Missing Number
You have been given an array containing N distinct integers taken from the range 1 to N+1. This means there is
one integer missing from the range. Your task is to write a program to find and return missing integer.
Input:
An integer N (1 <= N <= 10^5) representing the number of elements in the array.
N integers a1, a2, …., aN (1 <= al N+1) representing the elements of the array. Each element is distinct.
Output:
An integer representing the missing number in the range 1 to N+1
For example,
Input:7
1246378
Output:
5
--------------------------------------------------------------------------------------------------------------------------------------------------
05. Arjun has two types of Arrows. He wants to measure the length of them using a single measuring tape.
What will be the greatest possible length that can be used to measure exactly the length of two arrows? Write
a program to calculate this and help Arjun.
Example:
Input: 8 10
Output: The HCF of 8 and 10 is: 2
Input: 25 30
Output: The HCF of 25 and 30 is: 5
Please compile the code once in order to save it. Navigating to another question without compiling it will
result in losing the code.
--------------------------------------------------------------------------------------------------------------------------------------------------
06. This is a programming question. Please do not forget to select any one language from the "Select
Language” drop-down menu before you start coding. Please write your program in the given text area You can
check your program by clicking on the "Compile" button. Once your program is finalized you must submit your
program for evaluation by clicking on the "Submit" button. Also ensure that while printing the output of your
program, if required, you only print the exact output of the program, without any leading or preceding text or
remark.
Vaibhav needs a rectangular mat for his room. He measures the floor's length and width to find its area. Write
a program to calculate the area.
Example
Input: 3 3
Output: Area of floor 9
Input: 12 4
Output Area of floor 48
Please compile the code once in order to save it. Navigating to another question without compiling it will
result in losing the code.
--------------------------------------------------------------------------------------------------------------------------------------------------
07. Ram is a student who often gets confused with lowercase and uppercase letters. He has decided to write
an algorithm to resolve this issue. Given a string, you are required to determine whether it should be
converted to all uppercase or all lowercase, depending on the count of uppercase and lowercase letters in the
string.
Input
A string (1<<= 1000) consisting of both uppercase and lowercase letters.
Output
Return the corrected string it
--------------------------------------------------------------------------------------------------------------------------------------------------
08. Arun is a bus conductor. His ticket machine is printing numbers in reverse order due to a technical glitch. As
a programmer on the bus, you are asked to help him by creating a program to display the numbers correctly.
Example:
Input: 320
Output: Number in reverse order: 23
Input: 231
Output: Number in reverse order: 132
--------------------------------------------------------------------------------------------------------------------------------------------------
09. Write a function to calculate the sum of even numbers in a given list of integers. The function should take a
list of Integers as input and return the sum of all even numbers in the list.
Input:
numbers (1 <= len(numbers) <= 1000): A list of integers.
Output:
Return an Integer representing the sum of all even numbers in the list.
For example,
--------------------------------------------------------------------------------------------------------------------------------------------------