Thursday, 28 December 2017

We Will Be Back Soon....




Yes, you read it right, we will be back soon with more content, more questions, and even more answers.


First of all we would like to thank you all who have been to the blog and made it what it is right now.

Secondly we would request you to ask any question related to competitive programming or any queries you have in the comments section of this or any other post you feel like.

Thirdly if you don't find any question from the elab platform here and want it to be added all you need to do is this :

  1. Take a screenshot of the question and the sample test cases
  2. Upload it to Google Drive
  3. Send the link in the comments section of any post
The question will be attended to soon and an answer will be uploaded to the blog ASAP.

Finally we would like to thank you again for making 2017 a great year .

Wishing you a Happy New Year 2018

programmers@wttech

Saturday, 29 July 2017

Radius of a Circle

QUESTION DESCRIPTION

Madhan is handling mathematics to 8th grade. He taught area and perimeter of geometric shapes to his students. He thought to give a test based on triangle and circles.The task is to calculate radius of the circle that is inscribed in triangle given the three sides of the triangle. He has set 20 questions and he is tired of preparing answer keys.Write a program to find the radius of the circle inscribed in a triangle.

Input and Output Format :
Input consists of three integers a, b and c. The three integer
corresponds to three sides of a triangle.

TEST CASE 1


INPUT

3 4 5

OUTPUT

The radius of the circle is=1.00


EXPLANATION :

The code requires you to output the radius of a circle inscribed inside a triangle.
The input given is the three sides of the triangle and the output required is the radius of the circle that is inscribed inside the triangle in the specified format.

There are two basic geometric formula that can be used to get the desired result :
> r^2=(s-a)*(s-b)*(s-c)/s
> where s=(a+b+c)/2

The other method is  another format of the same formula that has been used above :

> r=((a+b-c)*(a+c-b)*(b+c-a))/2

ALGORITHM :
  • Accept the inputs in the program (int a,b,c)
  • Using either of the formulas calculate the value of the radius 
    • To calculate the square root of the equation the sqrt function is used, the header <math.h> needs to be imported to use the sqrt function.
  •  Print the radius with the desired tag "The radius of the circle is="

SOLUTION : (Please use this as reference only)

CODE

Sunday, 2 April 2017

No of Distinct Elements In An Unsorted Array

QUESTION DESCRIPTION

Write a program to find the number of distinct elements in a unsorted array. [Do it without sorting the array]

Input Format:
Input consists of n+1 integers. The first integer corresponds to n, the number of elements in the array. The next n integers correspond to the elements in the array. Assume that the maximum value of n is 15.

Output Format:
Output consists of a single integer which corresponds to the number of distinct elements in the array.


TEST CASE 1
 
INPUT

5
3 2 3 780 90

OUTPUT

4

TEST CASE 2

INPUT

10
1000 1001 1002 1003 2006 3005 2009 4006 5000 9000

OUTPUT

10


EXPLANATION :

The code requires you to count the number of unique elements present in an array .

ALGORITHM : 

  • Accept the number of elements in the array ( n )
  • Run a loop to accept the numbers into the array ( scanf("%d",&arr[i]) )
  • Remove the redundant elements by checking each number with the rest of the array elements and replacing all other occourances with -999999990
  • After removing the redundant elements count all elements other than -999999990 
  • Print the result.

SOLUTION : (Please use this as reference only)

CODE